Skip to content

Commit 4852c77

Browse files
author
Martin Jujou
authored
Merge pull request #4 from ah-simonkrix/lazyload-preload
Moved restoration of clickable flag from animation timer into a separate timer
2 parents 3c08bc9 + 96f4439 commit 4852c77

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

CHANGELOG.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# Change Log
22

33
## [Unreleased](https://github.com/akiran/react-slick/tree/HEAD)
4+
45
- Note
6+
57
- Project forked by Domain at this point to maintain this codebase.
68

7-
- Added
9+
- Added
810
- option to enable lazy loading for the closest slides images (for previous and next slide images) See example `LazyLoadClosestImages`
11+
- Fixed
12+
- Moved restoration of clickable flag from animation cooldown timer into another separate timer (AH-4429)
913

1014
## 0.22.0
1115

1216
**Release Changes**
1317

1418
- Internal Changes
19+
1520
- converted InnerSlider from createReactClass object to ES6 class
1621
- removed all the mixins, created classMethods and pure utility functions instead
1722
- changed autoplay from setTimeout to setInterval
@@ -41,12 +46,12 @@
4146
- fixed bugs due to uncleared callback timers
4247
- fixed update issues on just slider resize
4348

44-
4549
## 0.21.0
4650

4751
**Release Changes**
4852

4953
- Fixed issues
54+
5055
- dataset undefined error in case of swipeToSlide but finite slides
5156
- slideWidth issue by transform scale
5257
- variableWidth + finite alignment problems
@@ -55,6 +60,7 @@
5560
- fixed breaking of animation on setState
5661

5762
- Mixins to Pure Functions
63+
5864
- getWidth, getHeight
5965
- swipeDirection
6066
- initialize, update
@@ -80,7 +86,6 @@
8086
- implemented reInit event
8187
- implemented onSwipe event and documented edgeEvent
8288

83-
8489
## 0.19.0
8590

8691
**Release Changes**
@@ -97,7 +102,6 @@ Following are the changes to be mentioned:
97102
- responsive lazyloading bug fixed
98103
- increased verticalswiping resistance from 4 to 10
99104

100-
101105
## 0.18.0
102106

103107
**Major Changes:**
@@ -109,18 +113,17 @@ Following are the changes to be mentioned:
109113
- Modified logic for updating lazyLoadedList, earlier there were some whitespaces at ends, now they're gone
110114
- Fixed getTrackLeft issue for slideCount=1
111115

112-
113116
## 0.17.1
114117

115118
**Major Changes**
116119

117-
* Enforced some settings in specific configurations like:
118-
- `slidesToScroll = 1` *when fade is true*
119-
- `slidesToScroll = 1` *when centerMode is true*
120-
- `slidesToShow = 1` *when fade is true*
120+
- Enforced some settings in specific configurations like:
121121

122-
* Changed the number of clones (preclones and postclones), that fixed couple of issues like blank spaces after last slide and/or before first slide which occurred in several cases.
122+
- `slidesToScroll = 1` _when fade is true_
123+
- `slidesToScroll = 1` _when centerMode is true_
124+
- `slidesToShow = 1` _when fade is true_
123125

126+
- Changed the number of clones (preclones and postclones), that fixed couple of issues like blank spaces after last slide and/or before first slide which occurred in several cases.
124127

125128
**Minor Changes**
126129

src/inner-slider.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ export class InnerSlider extends React.Component {
118118
this.callbackTimers.forEach(timer => clearTimeout(timer));
119119
this.callbackTimers = [];
120120
}
121+
if (this.unblockClickableTimer) {
122+
clearTimeout(this.unblockClickableTimer);
123+
}
121124
if (window.addEventListener) {
122125
window.removeEventListener("resize", this.onWindowResized);
123126
} else {
@@ -264,9 +267,7 @@ export class InnerSlider extends React.Component {
264267
};
265268
if (this.props.centerMode) {
266269
let currentWidth = `${childrenWidths[this.state.currentSlide]}px`;
267-
trackStyle.left = `calc(${
268-
trackStyle.left
269-
} + (100% - ${currentWidth}) / 2 ) `;
270+
trackStyle.left = `calc(${trackStyle.left} + (100% - ${currentWidth}) / 2 ) `;
270271
}
271272
this.setState({
272273
trackStyle
@@ -276,15 +277,15 @@ export class InnerSlider extends React.Component {
276277
let childrenCount = React.Children.count(this.props.children);
277278
const spec = { ...this.props, ...this.state, slideCount: childrenCount };
278279
let slideCount = getPreClones(spec) + getPostClones(spec) + childrenCount;
279-
let trackWidth = 100 / this.props.slidesToShow * slideCount;
280+
let trackWidth = (100 / this.props.slidesToShow) * slideCount;
280281
let slideWidth = 100 / slideCount;
281282
let trackLeft =
282-
-slideWidth *
283-
(getPreClones(spec) + this.state.currentSlide) *
284-
trackWidth /
283+
(-slideWidth *
284+
(getPreClones(spec) + this.state.currentSlide) *
285+
trackWidth) /
285286
100;
286287
if (this.props.centerMode) {
287-
trackLeft += (100 - slideWidth * trackWidth / 100) / 2;
288+
trackLeft += (100 - (slideWidth * trackWidth) / 100) / 2;
288289
}
289290
let trackStyle = {
290291
width: trackWidth + "%",
@@ -474,6 +475,9 @@ export class InnerSlider extends React.Component {
474475
let triggerSlideHandler = state["triggerSlideHandler"];
475476
delete state["triggerSlideHandler"];
476477
this.setState(state);
478+
this.unblockClickableTimer = setTimeout(() => {
479+
this.clickable = true;
480+
}, this.props.speed);
477481
if (triggerSlideHandler === undefined) return;
478482
this.slideHandler(triggerSlideHandler);
479483
if (this.props.verticalSwiping) {

0 commit comments

Comments
 (0)