Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #15

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix Typo in index.js
boundsPaddding -> boundsPadding
  • Loading branch information
odai-alali committed Nov 9, 2017
commit 82129fe0c4332c7e038ed08b63fdf3a971448b8d
59 changes: 54 additions & 5 deletions dist/panzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = createPanZoom;

/**
* Creates a new instance of panzoom, so that an object can be panned and zoomed
*
*
* @param {DOMElement} domElement where panzoom should be attached.
* @param {Object} options that configure behavior.
*/
Expand Down Expand Up @@ -51,7 +51,7 @@ function createPanZoom(domElement, options) {
var maxZoom = typeof options.maxZoom === 'number' ? options.maxZoom : Number.POSITIVE_INFINITY
var minZoom = typeof options.minZoom === 'number' ? options.minZoom : 0

var boundsPadding = typeof options.boundsPaddding === 'number' ? options.boundsPaddding : 0.05
var boundsPadding = typeof options.boundsPadding === 'number' ? options.boundsPadding : 0.05
var zoomDoubleClickSpeed = typeof options.zoomDoubleClickSpeed === 'number' ? options.zoomDoubleClickSpeed : defaultDoubleTapZoomSpeed
var beforeWheel = options.beforeWheel || noop
var speed = typeof options.zoomSpeed === 'number' ? options.zoomSpeed : defaultZoomSpeed
Expand Down Expand Up @@ -80,7 +80,7 @@ function createPanZoom(domElement, options) {
var smoothScroll
if ('smoothScroll' in options && !options.smoothScroll) {
// If user explicitly asked us not to use smooth scrolling, we obey
smoothScroll = rigidScroll()
smoothScroll = rigidScroll()
} else {
// otherwise we use forward smoothScroll settings to kinetic API
// which makes scroll smoothing.
Expand Down Expand Up @@ -696,6 +696,7 @@ function rigidScroll() {
cancel: noop
}
}

},{"./lib/createEvent.js":2,"./lib/domController.js":3,"./lib/kinetic.js":4,"./lib/svgController.js":5,"./lib/textSlectionInterceptor.js":6,"./lib/transform.js":7,"amator":8,"wheel":10}],2:[function(require,module,exports){
/* global Event */
module.exports = createEvent;
Expand Down Expand Up @@ -1003,9 +1004,12 @@ var animations = {


module.exports = animate;
module.exports.makeAggregateRaf = makeAggregateRaf;
module.exports.sharedScheduler = makeAggregateRaf();


function animate(source, target, options) {
var start= Object.create(null)
var start = Object.create(null)
var diff = Object.create(null)
options = options || {}
// We let clients specify their own easing function
Expand All @@ -1030,7 +1034,7 @@ function animate(source, target, options) {
diff[key] = target[key] - source[key]
})

var durationInMs = options.duration || 400
var durationInMs = typeof options.duration === 'number' ? options.duration : 400
var durationInFrames = Math.max(1, durationInMs * 0.06) // 0.06 because 60 frames pers 1,000 ms
var previousAnimationId
var frame = 0
Expand Down Expand Up @@ -1097,6 +1101,51 @@ function timeoutScheduler() {
}
}

function makeAggregateRaf() {
var frontBuffer = new Set();
var backBuffer = new Set();
var frameToken = 0;

return {
next: next,
cancel: next,
clearAll: clearAll
}

function clearAll() {
frontBuffer.clear();
backBuffer.clear();
cancelAnimationFrame(frameToken);
frameToken = 0;
}

function next(callback) {
backBuffer.add(callback);
renderNextFrame();
}

function renderNextFrame() {
if (!frameToken) frameToken = requestAnimationFrame(renderFrame);
}

function renderFrame() {
frameToken = 0;

var t = backBuffer;
backBuffer = frontBuffer;
frontBuffer = t;

frontBuffer.forEach(function(callback) {
callback();
});
frontBuffer.clear();
}

function cancel(callback) {
backBuffer.delete(callback);
}
}

},{"bezier-easing":9}],9:[function(require,module,exports){
/**
* https://github.com/gre/bezier-easing
Expand Down
2 changes: 1 addition & 1 deletion dist/panzoom.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = createPanZoom;

/**
* Creates a new instance of panzoom, so that an object can be panned and zoomed
*
*
* @param {DOMElement} domElement where panzoom should be attached.
* @param {Object} options that configure behavior.
*/
Expand Down Expand Up @@ -50,7 +50,7 @@ function createPanZoom(domElement, options) {
var maxZoom = typeof options.maxZoom === 'number' ? options.maxZoom : Number.POSITIVE_INFINITY
var minZoom = typeof options.minZoom === 'number' ? options.minZoom : 0

var boundsPadding = typeof options.boundsPaddding === 'number' ? options.boundsPaddding : 0.05
var boundsPadding = typeof options.boundsPadding === 'number' ? options.boundsPadding : 0.05
var zoomDoubleClickSpeed = typeof options.zoomDoubleClickSpeed === 'number' ? options.zoomDoubleClickSpeed : defaultDoubleTapZoomSpeed
var beforeWheel = options.beforeWheel || noop
var speed = typeof options.zoomSpeed === 'number' ? options.zoomSpeed : defaultZoomSpeed
Expand Down Expand Up @@ -79,7 +79,7 @@ function createPanZoom(domElement, options) {
var smoothScroll
if ('smoothScroll' in options && !options.smoothScroll) {
// If user explicitly asked us not to use smooth scrolling, we obey
smoothScroll = rigidScroll()
smoothScroll = rigidScroll()
} else {
// otherwise we use forward smoothScroll settings to kinetic API
// which makes scroll smoothing.
Expand Down Expand Up @@ -694,4 +694,4 @@ function rigidScroll() {
stop: noop,
cancel: noop
}
}
}
Loading