Skip to content

Commit 65cb867

Browse files
Bug Fix: Drag performance.
1 parent 92bdc5e commit 65cb867

File tree

10 files changed

+25
-19
lines changed

10 files changed

+25
-19
lines changed

dist/js/splide-renderer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.cjs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Splide.js
3-
* Version : 3.0.1
3+
* Version : 3.0.2
44
* License : MIT
55
* Copyright: 2021 Naotoshi Fujita
66
*/
@@ -1726,6 +1726,7 @@ const POINTER_UP_EVENTS = "touchend touchcancel mouseup mouseleave";
17261726
function Drag(Splide2, Components2, options) {
17271727
const { on, emit, bind, unbind } = EventInterface(Splide2);
17281728
const { Move, Scroll, Controller } = Components2;
1729+
const { ruleBy } = Components2.Style;
17291730
const { track } = Components2.Elements;
17301731
const { resolve, orient } = Components2.Direction;
17311732
const { getPosition, exceededLimit } = Move;
@@ -1765,9 +1766,9 @@ function Drag(Splide2, Components2, options) {
17651766
bind(target, POINTER_UP_EVENTS, onPointerUp);
17661767
Move.cancel();
17671768
Scroll.cancel();
1769+
ruleBy(track, "will-change", "transform");
17681770
save(e);
1769-
}
1770-
if (e.cancelable) {
1771+
} else {
17711772
prevent(e, true);
17721773
}
17731774
}
@@ -1802,6 +1803,7 @@ function Drag(Splide2, Components2, options) {
18021803
}
18031804
function onPointerUp(e) {
18041805
unbind(target, `${POINTER_MOVE_EVENTS} ${POINTER_UP_EVENTS}`);
1806+
ruleBy(track, "will-change", "");
18051807
if (lastEvent) {
18061808
if (isDragging || e.cancelable && isSliderDirection()) {
18071809
const velocity = computeVelocity(e);

dist/js/splide.esm.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Splide.js
3-
* Version : 3.0.1
3+
* Version : 3.0.2
44
* License : MIT
55
* Copyright: 2021 Naotoshi Fujita
66
*/
@@ -1722,6 +1722,7 @@ const POINTER_UP_EVENTS = "touchend touchcancel mouseup mouseleave";
17221722
function Drag(Splide2, Components2, options) {
17231723
const { on, emit, bind, unbind } = EventInterface(Splide2);
17241724
const { Move, Scroll, Controller } = Components2;
1725+
const { ruleBy } = Components2.Style;
17251726
const { track } = Components2.Elements;
17261727
const { resolve, orient } = Components2.Direction;
17271728
const { getPosition, exceededLimit } = Move;
@@ -1761,9 +1762,9 @@ function Drag(Splide2, Components2, options) {
17611762
bind(target, POINTER_UP_EVENTS, onPointerUp);
17621763
Move.cancel();
17631764
Scroll.cancel();
1765+
ruleBy(track, "will-change", "transform");
17641766
save(e);
1765-
}
1766-
if (e.cancelable) {
1767+
} else {
17671768
prevent(e, true);
17681769
}
17691770
}
@@ -1798,6 +1799,7 @@ function Drag(Splide2, Components2, options) {
17981799
}
17991800
function onPointerUp(e) {
18001801
unbind(target, `${POINTER_MOVE_EVENTS} ${POINTER_UP_EVENTS}`);
1802+
ruleBy(track, "will-change", "");
18011803
if (lastEvent) {
18021804
if (isDragging || e.cancelable && isSliderDirection()) {
18031805
const velocity = computeVelocity(e);

dist/js/splide.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js.gz

23 Bytes
Binary file not shown.

dist/types/components/Drag/Drag.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splidejs/splide",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "Splide is a lightweight, flexible and accessible slider/carousel. No dependencies, no Lighthouse errors.",
55
"author": "Naotoshi Fujita",
66
"license": "MIT",

src/js/components/Drag/Drag.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface DragComponent extends BaseComponent {
3030
export function Drag( Splide: Splide, Components: Components, options: Options ): DragComponent {
3131
const { on, emit, bind, unbind } = EventInterface( Splide );
3232
const { Move, Scroll, Controller } = Components;
33+
const { ruleBy } = Components.Style;
3334
const { track } = Components.Elements;
3435
const { resolve, orient } = Components.Direction;
3536
const { getPosition, exceededLimit } = Move;
@@ -132,10 +133,9 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
132133
bind( target, POINTER_UP_EVENTS, onPointerUp );
133134
Move.cancel();
134135
Scroll.cancel();
136+
ruleBy( track, 'will-change', 'transform' );
135137
save( e );
136-
}
137-
138-
if ( e.cancelable ) {
138+
} else {
139139
prevent( e, true );
140140
}
141141
}
@@ -190,6 +190,7 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
190190
*/
191191
function onPointerUp( e: TouchEvent | MouseEvent ): void {
192192
unbind( target, `${ POINTER_MOVE_EVENTS } ${ POINTER_UP_EVENTS }` );
193+
ruleBy( track, 'will-change', '' );
193194

194195
if ( lastEvent ) {
195196
if ( isDragging || ( e.cancelable && isSliderDirection() ) ) {

0 commit comments

Comments
 (0)