Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf3c8df7

Browse files
author
Andrey Nelyubin
committed
Ensuring that drag does not move slides more thanoptions.flickMaxPages allows
1 parentd7e1f08 commitf3c8df7

File tree

10 files changed

+43
-13
lines changed

10 files changed

+43
-13
lines changed

‎dist/js/splide-renderer.min.js‎

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

‎dist/js/splide-renderer.min.js.map‎

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

‎dist/js/splide.cjs.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Splide.js
33
* Version : 4.1.4
44
* License : MIT
5-
* Copyright:2022 Naotoshi Fujita
5+
* Copyright:2023 Naotoshi Fujita
66
*/
77
'use strict';
88

@@ -2264,7 +2264,11 @@ function Drag(Splide2, Components2, options) {
22642264
}elseif(Splide2.is(SLIDE)&&exceeded&&rewind){
22652265
Controller.go(exceededLimit(true) ?">" :"<");
22662266
}else{
2267-
Controller.go(Controller.toDest(destination),true);
2267+
varsign1=sign(velocity);
2268+
varexpectedDestination=Controller.toDest(destination);
2269+
varmaxPages=options.flickMaxPages||1;
2270+
vargoTo=sign1<0 ?min(expectedDestination,Splide2.index+maxPages) :max(expectedDestination,Splide2.index-maxPages);
2271+
Controller.go(goTo,true);
22682272
}
22692273

22702274
reduce(true);

‎dist/js/splide.esm.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
66
* Splide.js
77
* Version : 4.1.4
88
* License : MIT
9-
* Copyright:2022 Naotoshi Fujita
9+
* Copyright:2023 Naotoshi Fujita
1010
*/
1111
varMEDIA_PREFERS_REDUCED_MOTION="(prefers-reduced-motion: reduce)";
1212
varCREATED=1;
@@ -2259,7 +2259,11 @@ function Drag(Splide2, Components2, options) {
22592259
}elseif(Splide2.is(SLIDE)&&exceeded&&rewind){
22602260
Controller.go(exceededLimit(true) ?">" :"<");
22612261
}else{
2262-
Controller.go(Controller.toDest(destination),true);
2262+
varsign1=sign(velocity);
2263+
varexpectedDestination=Controller.toDest(destination);
2264+
varmaxPages=options.flickMaxPages||1;
2265+
vargoTo=sign1<0 ?min(expectedDestination,Splide2.index+maxPages) :max(expectedDestination,Splide2.index-maxPages);
2266+
Controller.go(goTo,true);
22632267
}
22642268

22652269
reduce(true);

‎dist/js/splide.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
66
* Splide.js
77
* Version : 4.1.4
88
* License : MIT
9-
* Copyright:2022 Naotoshi Fujita
9+
* Copyright:2023 Naotoshi Fujita
1010
*/
1111
(function(global,factory){
1212
typeofexports==='object'&&typeofmodule!=='undefined' ?module.exports=factory() :typeofdefine==='function'&&define.amd ?define(factory) :(global=typeofglobalThis!=='undefined' ?globalThis :global||self,global.Splide=factory());
@@ -2257,7 +2257,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
22572257
}elseif(Splide2.is(SLIDE)&&exceeded&&rewind){
22582258
Controller.go(exceededLimit(true) ?">" :"<");
22592259
}else{
2260-
Controller.go(Controller.toDest(destination),true);
2260+
varsign1=sign(velocity);
2261+
varexpectedDestination=Controller.toDest(destination);
2262+
varmaxPages=options.flickMaxPages||1;
2263+
vargoTo=sign1<0 ?min(expectedDestination,Splide2.index+maxPages) :max(expectedDestination,Splide2.index-maxPages);
2264+
Controller.go(goTo,true);
22612265
}
22622266

22632267
reduce(true);

‎dist/js/splide.min.js‎

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

‎dist/js/splide.min.js.gz‎

30 Bytes
Binary file not shown.

‎dist/js/splide.min.js.map‎

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

‎src/js/components/Drag/Drag.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FADE, LOOP, SLIDE } from '../../constants/types';
66
import{EventInterface}from'../../constructors';
77
import{Splide}from'../../core/Splide/Splide';
88
import{BaseComponent,Components,Options}from'../../types';
9-
import{abs,isObject,matches,min,noop,prevent,sign,timeOf}from'../../utils';
9+
import{abs,isObject,matches,min,max,noop,prevent,sign,timeOf}from'../../utils';
1010
import{FRICTION,LOG_INTERVAL,POINTER_DOWN_EVENTS,POINTER_MOVE_EVENTS,POINTER_UP_EVENTS}from'./constants';
1111

1212

@@ -237,7 +237,11 @@ export function Drag( Splide: Splide, Components: Components, options: Options )
237237
}elseif(Splide.is(SLIDE)&&exceeded&&rewind){
238238
Controller.go(exceededLimit(true) ?'>' :'<');
239239
}else{
240-
Controller.go(Controller.toDest(destination),true);
240+
constsign1=sign(velocity);
241+
constexpectedDestination=Controller.toDest(destination);
242+
constmaxPages=options.flickMaxPages||1;
243+
constgoTo=sign1<0 ?min(expectedDestination,Splide.index+maxPages) :max(expectedDestination,Splide.index-maxPages);
244+
Controller.go(goTo,true);
241245
}
242246

243247
reduce(true);

‎src/js/components/Drag/test/general.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ describe( 'Drag', () => {
6060
expect(splide.index).toBe(0);
6161
});
6262

63+
test.each([1,2])('should change the slide index no longer than flickMaxPages (%s).',(flickMaxPages)=>{
64+
constwidth=600;
65+
constxOffset=width*flickMaxPages;
66+
constsplide=init({speed:0, width, flickMaxPages});
67+
consttrack=splide.Components.Elements.track;
68+
69+
fireWithCoord(track,'mousedown',{x:0,timeStamp:1});
70+
fireWithCoord(window,'mousemove',{x:1,timeStamp:1});
71+
fireWithCoord(window,'mousemove',{x:-20-xOffset,timeStamp:100});
72+
fireWithCoord(window,'mouseup',{x:-20-xOffset,timeStamp:100});
73+
74+
expect(splide.index).toBe(flickMaxPages);
75+
});
76+
6377
test('should start moving the slider immediately if the pointing device is a mouse.',()=>{
6478
constsplide=init();
6579
constonDrag=jest.fn();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp