diff --git a/README.md b/README.md index 154ecf4..8f0e61a 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,8 @@ Jump.jump('.selector', { if(t < 1) return c / 2 * t * t + b t-- return -c / 2 * (t * (t - 2) - 1) + b - } + }, + container: '.selector' }) ``` @@ -144,6 +145,16 @@ Jump.jump('.selector', { }) ``` +##### container + +Container when you want to `jump()` inside an element. + +```es6 +Jump.jump('.selector', { + container: '.selector' +}) +``` + ## Browser Support Jump depends on the following browser APIs: diff --git a/dist/jump.min.js b/dist/jump.min.js index cd79787..c671434 100644 --- a/dist/jump.min.js +++ b/dist/jump.min.js @@ -3,4 +3,4 @@ * Copyright (c) 2015 Michael Cavalea - https://github.com/callmecavs/jump.js * License: MIT */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Jump=t()}}(function(){return function t(e,n,i){function o(s,u){if(!n[s]){if(!e[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(r)return r(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[s]={exports:{}};e[s][0].call(l.exports,function(t){var n=e[s][1][t];return o(n?n:t)},l,l.exports,t,e,n,i)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;st?n/2*t*t+e:(t--,-n/2*(t*(t-2)-1)+e)},e.exports=n["default"]},{}],2:[function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;nt?n/2*t*t+e:(t--,-n/2*(t*(t-2)-1)+e)},e.exports=n["default"]},{}],2:[function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n this._loop(time)) @@ -38,7 +41,10 @@ export default class Jump { } _end() { - window.scrollTo(0, this.start + this.distance) + + !!this.options.container + ? this.options.container.scrollTop = this.options.container.getBoundingClientRect().top + this.next + this.distance + : window.scrollTo(0, this.next + this.distance) typeof this.options.callback === 'function' && this.options.callback() this.timeStart = false