Skip to content

Commit

Permalink
updated var(s) to let and const to follow popular view that var shoul…
Browse files Browse the repository at this point in the history
…d be deprecated for the following reasons: https://wesbos.com/let-vs-const/ and  https://mathiasbynens.be/notes/es6-const
  • Loading branch information
Hillsie committed May 23, 2019
1 parent ae049ff commit 06806e7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jquery.html
docs/fonts/
docs/ajax-loader.gif
package-lock.json
.DS_Store
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"autoprefixer": "^7.1.2",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.4.2",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.4",
"babel-preset-airbnb": "^2.1.1",
"css-loader": "^0.28.0",
"css-loader": "^2.1.1",
"deepmerge": "^1.1.0",
"del": "^2.2.2",
"enzyme": "^3.2.0",
Expand All @@ -59,7 +59,7 @@
"gulp-sass": "^4.0.0",
"husky": "^0.14.3",
"jasmine-core": "^2.5.2",
"jest": "^23.6.0",
"jest": "^24.8.0",
"jquery": "^3.2.1",
"js-beautify": "^1.7.5",
"json-loader": "^0.5.4",
Expand Down
2 changes: 1 addition & 1 deletion src/default-props.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

var defaultProps = {
let defaultProps = {
accessibility: true,
adaptiveHeight: false,
afterChange: null,
Expand Down
18 changes: 9 additions & 9 deletions src/dots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from "react";
import classnames from "classnames";

var getDotCount = function(spec) {
var dots;
const getDotCount = spec => {
let dots;

if (spec.infinite) {
dots = Math.ceil(spec.slideCount / spec.slidesToScroll);
Expand All @@ -25,7 +25,7 @@ export class Dots extends React.PureComponent {
this.props.clickHandler(options);
}
render() {
var dotCount = getDotCount({
let dotCount = getDotCount({
slideCount: this.props.slideCount,
slidesToScroll: this.props.slidesToScroll,
slidesToShow: this.props.slidesToShow,
Expand All @@ -37,29 +37,29 @@ export class Dots extends React.PureComponent {
// Credit: http://stackoverflow.com/a/13735425/1849458
const { onMouseEnter, onMouseOver, onMouseLeave } = this.props;
const mouseEvents = { onMouseEnter, onMouseOver, onMouseLeave };
var dots = Array.apply(
let dots = Array.apply(
null,
Array(dotCount + 1)
.join("0")
.split("")
).map((x, i) => {
var leftBound = i * this.props.slidesToScroll;
var rightBound =
let leftBound = i * this.props.slidesToScroll;
let rightBound =
i * this.props.slidesToScroll + (this.props.slidesToScroll - 1);
var className = classnames({
let className = classnames({
"slick-active":
this.props.currentSlide >= leftBound &&
this.props.currentSlide <= rightBound
});

var dotOptions = {
let dotOptions = {
message: "dots",
index: i,
slidesToScroll: this.props.slidesToScroll,
currentSlide: this.props.currentSlide
};

var onClick = this.clickHandler.bind(this, dotOptions);
let onClick = this.clickHandler.bind(this, dotOptions);
return (
<li key={i} className={className}>
{React.cloneElement(this.props.customPaging(i), { onClick })}
Expand Down
28 changes: 14 additions & 14 deletions src/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from "./utils/innerSliderUtils";

// given specifications/props for a slide, fetch all the classes that need to be applied to the slide
var getSlideClasses = spec => {
var slickActive, slickCenter, slickCloned;
var centerOffset, index;
const getSlideClasses = spec => {
let slickActive, slickCenter, slickCloned;
let centerOffset, index;

if (spec.rtl) {
index = spec.slideCount - 1 - spec.index;
Expand Down Expand Up @@ -43,8 +43,8 @@ var getSlideClasses = spec => {
};
};

var getSlideStyle = function(spec) {
var style = {};
const getSlideStyle = spec => {
let style = {};

if (spec.variableWidth === undefined || spec.variableWidth === false) {
style.width = spec.slideWidth;
Expand Down Expand Up @@ -85,18 +85,18 @@ var getSlideStyle = function(spec) {

const getKey = (child, fallbackKey) => child.key || fallbackKey;

var renderSlides = function(spec) {
var key;
var slides = [];
var preCloneSlides = [];
var postCloneSlides = [];
var childrenCount = React.Children.count(spec.children);
const renderSlides = spec => {
let key;
let slides = [];
let preCloneSlides = [];
let postCloneSlides = [];
let childrenCount = React.Children.count(spec.children);
let startIndex = lazyStartIndex(spec);
let endIndex = lazyEndIndex(spec);

React.Children.forEach(spec.children, (elem, index) => {
let child;
var childOnClickOptions = {
let childOnClickOptions = {
message: "children",
index: index,
slidesToScroll: spec.slidesToScroll,
Expand All @@ -112,8 +112,8 @@ var renderSlides = function(spec) {
} else {
child = <div />;
}
var childStyle = getSlideStyle({ ...spec, index });
const slideClass = child.props.className || "";
let childStyle = getSlideStyle({ ...spec, index });
let slideClass = child.props.className || "";
let slideClasses = getSlideClasses({ ...spec, index });
// push a cloned element of the desired slide
slides.push(
Expand Down

0 comments on commit 06806e7

Please sign in to comment.