Comments (11)
As a quick follow-up question - is this the correct way to scroll the full browser window using velocity?
$('html')
.velocity('stop')
.velocity('scroll', { duration: 750, offset: top - 100 });
from velocity.
Hey Chip!
Very good question.
We'll start with the basics: Velocity doesn't support animating scrollTop property like $.animate() does. (It's not a real property -- jQuery shimmed it.)
Scrolling in Velocity is only achieved by the "scroll" command -- as demonstrated in your last example. It results in a cleaner interface with more performant code.
With that out of the way, let's get to the bottom of your issue: You're trying to scroll to an element within a container element that has scrollbars. When you use the correct Velocity scroll syntax (as mentioned), Velocity only brings you to the top of the container element, but doesn't go a step further by also scrolling the container down to the position of the targeted element?
from velocity.
Sorry if being dense here, can't work out how to scroll the innards of the container then.
With jQuery I can do:
$(".ref").hover( function(event) {
event.preventDefault();
container.stop().animate({ scrollTop: containerHeight }, 2000);
}, function(){
container.stop(); // unhover - stop
} );
When switching out animate for velocity and scrollTop for scroll the page scrolls - not the container?
Can I achieve the container contents scrolling with velocity?
Thanks in advance
P.S. What you're achieving here is awesome so Props!!!! Big time :)
from velocity.
@julianshapiro you nailed it. I love the new scroll syntax - it just doesn't scroll inside the a container div. When I make the container element the first in the chain (eg. .pickup-locations above) the window is scrolled to the container element as expected. When I change the first element to be the item I'd like to scroll to - it still scrolls the window:
$('.pickup-location-item')
.velocity('stop')
.velocity('scroll', { duration: 1000 });
What would be nice is another parameter in the options object for 'container' so that we could do this:
$('.pickup-location-item')
.velocity('stop')
.velocity('scroll', { duration: 1000, container: '.pickup-locations' });
and the '.pickup-locations' div would 'scroll' to have the '.pickup-location-item' at the top of its container.
Thoughts? Thanks again!
from velocity.
It's definitely happening. Today, in fact :) Stay tuned.
Thanks so much, Chip.
from velocity.
Rock n' Roll
from velocity.
Yes, you should definately implement this. ;)
from velocity.
Well, I couldn't have asked for anything more! :D
from velocity.
@chiplay, @AshleySheinwald, @Merg1255 , @scooterlord
Thanks to you guys, this feature has been added to Velocity.
See documentation for details on use: http://julian.com/research/velocity/#scroll -- should be intuitive and very performant.
Go ahead and update your copies of Velocity with the raw GitHub files (the MaxCDN link is usually a couple hours out of date).
from velocity.
@julianshapiro incredible! Works great - thanks for making this happen. Excited to start pushing our animations to new levels. (our mobile web app https://m.relayfoods.com - currently uses Zepto for animations, will be using Velocity soon)
from velocity.
Beautiful. This is why I spend time on Velocity. Because I love it when people show me what they make with it :-)
When it's converted to Velocity, tweet to me and I can link to relay and your own portfolio in the upcoming Velocity gallery.
Sent from my phone.
On May 2, 2014, at 7:49 PM, Chip Lay [email protected] wrote:
@julianshapiro incredible! Works great - thanks for making this happen. Excited to start pushing our animations to new levels. (our mobile web app https://m.relayfoods.com - currently uses Zepto for animations, will be using Velocity soon)
—
Reply to this email directly or view it on GitHub.
from velocity.
Related Issues (20)
- I accidently "pushed" two files into velocity HOT 2
- http://velocityjs.org/ insecure connection HOT 2
- Velocity 'registerNormalization' warning during Vue Unit Testing HOT 2
- Move to org HOT 1
- animation with property 'transfrom' in velocity does not work and an error appear instead HOT 1
- Security issue - How to report you about it ? HOT 3
- Animating scrollTop on scrollable elements HOT 4
- velocity ios transform do not work HOT 2
- Chaining produces error "e.replace is not a function." HOT 1
- VelocityJS: Missing pattern: padding
- VelocityJS: Missing pattern: padding HOT 2
- how to use velocity without jquery/zepto? HOT 1
- Velocity v3 and the future HOT 7
- Changing width and translate at the same time causes crash HOT 2
- scrollTop property not working as expected
- Is there a way to allow transition animation?
- How to easing like specialEasing of jQuery animate?
- Force velocity to attach itself to the window object even if jQuery is installed HOT 1
- The must-see 3D demo youtube video is private? HOT 2
- "This expression is not a callable" when instanciating Velocity HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from velocity.