embla-carousel
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -20,2 +20,3 @@ import { Animation } from './animation'; | ||
loop: boolean; | ||
onSelect(): void; | ||
} | ||
@@ -22,0 +23,0 @@ export interface DragBehaviour { |
@@ -16,6 +16,2 @@ import { Animation } from './animation'; | ||
index: Counter; | ||
nodes: { | ||
container: HTMLElement; | ||
slides: HTMLElement[]; | ||
}; | ||
pointer: DragBehaviour; | ||
@@ -22,0 +18,0 @@ target: Vector1D; |
@@ -10,3 +10,3 @@ import { Animation } from './animation'; | ||
findTarget: TargetFinder; | ||
onTravel(): void; | ||
onSelect(): void; | ||
} | ||
@@ -13,0 +13,0 @@ export interface Traveller { |
@@ -0,1 +1,2 @@ | ||
import { Animation } from './animation'; | ||
import { Limit } from './limit'; | ||
@@ -8,3 +9,3 @@ import { Mover } from './mover'; | ||
mover: Mover; | ||
offset: number; | ||
animation: Animation; | ||
} | ||
@@ -11,0 +12,0 @@ export interface VectorBounds { |
@@ -713,2 +713,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var target = vector1d_1.Vector1D(startLocation); | ||
var onSelect = function onSelect() { | ||
return options.onSelect(slider.index.get()); | ||
}; | ||
var mover = mover_1.Mover({ | ||
@@ -730,5 +735,3 @@ location: location, | ||
moverTarget: target, | ||
onTravel: function onTravel() { | ||
options.onSelect(slider.index.get()); | ||
} | ||
onSelect: onSelect | ||
}); // Pointer | ||
@@ -744,2 +747,3 @@ | ||
mover: mover, | ||
onSelect: onSelect, | ||
pointer: pointer_1.Pointer(chunkSize), | ||
@@ -753,6 +757,6 @@ target: target, | ||
bounds: vectorBounds_1.VectorBounds({ | ||
animation: animation, | ||
limit: limit, | ||
location: location, | ||
mover: mover, | ||
offset: 30 | ||
mover: mover | ||
}), | ||
@@ -767,6 +771,2 @@ index: index, | ||
mover: mover, | ||
nodes: { | ||
container: container, | ||
slides: slides | ||
}, | ||
pointer: pointer, | ||
@@ -1074,3 +1074,3 @@ shifter: infiniteShifter_1.InfiniteShifter({ | ||
var pastLimit = limit.reached.any(location.get()); | ||
var resist = !loop && pastLimit ? 2.5 : 1; | ||
var resist = !loop && pastLimit ? 2 : 1; | ||
location.addNumber(diff / resist); | ||
@@ -1094,10 +1094,9 @@ } else { | ||
mover = params.mover, | ||
index = params.index; | ||
var force = pointer.up(); | ||
index = params.index, | ||
onSelect = params.onSelect; | ||
var force = pointer.up() * (state.isMouse ? 1 : 2.4); | ||
var forceAbs = Math.abs(force); | ||
var low = state.isMouse ? 11 : 18; | ||
var high = state.isMouse ? 15 : 20; | ||
var speedLimit = limit_1.Limit({ | ||
low: low, | ||
high: high | ||
low: 11, | ||
high: 15 | ||
}); | ||
@@ -1110,7 +1109,12 @@ var speed = speedLimit.constrain(forceAbs); | ||
if (!loop && forceAbs < 10) { | ||
var pastLowLimit = limit.reached.low(location.get()); | ||
var pastHighLimit = limit.reached.high(location.get()); | ||
if (!loop) { | ||
var targetLocation = location.get() + force; | ||
var pastLowLimit = limit.reached.low(targetLocation); | ||
var pastHighLimit = limit.reached.high(targetLocation); | ||
if (pastHighLimit && index.get() === index.min || pastLowLimit && index.get() === index.max) { | ||
if (pastHighLimit || pastLowLimit) { | ||
var nextIndex = pastHighLimit ? index.min : index.max; | ||
target.setNumber(targetLocation); | ||
index.set(nextIndex); | ||
onSelect(); | ||
return; | ||
@@ -1634,7 +1638,7 @@ } | ||
function travelTo(next) { | ||
var onTravel = params.onTravel; | ||
var onSelect = params.onSelect; | ||
animation.start(); | ||
moverTarget.addNumber(next.distance); | ||
index.set(next.index); | ||
onTravel(); | ||
onSelect(); | ||
return self; | ||
@@ -1705,14 +1709,25 @@ } | ||
var limit = params.limit, | ||
offset = params.offset, | ||
location = params.location, | ||
mover = params.mover; | ||
mover = params.mover, | ||
animation = params.animation; | ||
var state = { | ||
timeout: 0 | ||
}; | ||
function shouldConstrain(v) { | ||
var l = location.get(); | ||
var isLowLimit = v.get() === limit.low; | ||
var isHighLimit = v.get() === limit.high; | ||
return limit.reached.low(l) && !isLowLimit || limit.reached.high(l) && !isHighLimit; | ||
} | ||
function constrain(v) { | ||
var lowLocationWithOffset = location.get() + offset; | ||
var highLocationWithOffset = location.get() - offset; | ||
if (limit.reached.low(lowLocationWithOffset) || limit.reached.high(highLocationWithOffset)) { | ||
if (!state.timeout && shouldConstrain(v)) { | ||
var constraint = limit.constrain(v.get()); | ||
v.setNumber(constraint); | ||
mover.useSpeed(10); | ||
state.timeout = window.setTimeout(function () { | ||
v.setNumber(constraint); | ||
mover.useSpeed(10); | ||
animation.start(); | ||
state.timeout = 0; | ||
}, 50); | ||
} | ||
@@ -1719,0 +1734,0 @@ |
{ | ||
"name": "embla-carousel", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"author": "David Cetinkaya", | ||
@@ -24,2 +24,3 @@ "private": false, | ||
], | ||
"browserslist": "last 5 versions", | ||
"main": "lib/index.js", | ||
@@ -29,6 +30,11 @@ "types": "lib/index.d.ts", | ||
"test": "jest --config jestconfig.json", | ||
"start": "webpack-dev-server --config ./webpack/webpack.config.development", | ||
"build:lib": "webpack -p --config ./webpack/webpack.config.production", | ||
"build:sandbox": "webpack -p --config ./webpack/webpack.config.sandbox", | ||
"build": "npm run build:lib && npm run build:sandbox", | ||
"start": "npm-run-all --parallel docs:watch-css lib:watch-js", | ||
"lib:watch-js": "webpack-dev-server --config ./webpack/webpack.config.development", | ||
"lib:build-js": "webpack -p --config ./webpack/webpack.config.production", | ||
"docs:autoprefixer": "postcss -u autoprefixer -r docs/assets/style.css --nomap", | ||
"docs:watch-css": "node-sass --watch --recursive docs/scss/style.scss -o docs/assets/", | ||
"docs:build-css": "node-sass --output-style compressed docs/scss/style.scss -o docs/assets/", | ||
"docs:build-js": "webpack -p --config ./webpack/webpack.config.docs", | ||
"docs:build": "npm-run-all docs:build-js docs:build-css", | ||
"build": "npm-run-all lib:build-js docs:build", | ||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", | ||
@@ -48,2 +54,3 @@ "lint": "tslint -p tsconfig.json", | ||
"@types/jest-diff": "^20.0.0", | ||
"autoprefixer": "^9.5.0", | ||
"awesome-typescript-loader": "^5.2.1", | ||
@@ -53,2 +60,5 @@ "babel-loader": "^8.0.5", | ||
"jest": "^24.0.0", | ||
"node-sass": "^4.11.0", | ||
"npm-run-all": "^4.1.5", | ||
"postcss-cli": "^6.1.2", | ||
"prettier": "^1.16.4", | ||
@@ -55,0 +65,0 @@ "ts-jest": "^23.10.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62503
1784
21