Scrolling
iOS 5 Beta 2 unveils Native Momentum Scrolling in CSS
In iOS 5 we will be able to use the nice velocity / momentum base scrolling through CSS in Safari.
Identified by Johan Brook, at Native style momentum scrolling to arrive in iOS 5, the new functionality will be a nice addition to web based iOS apps and websites.
The CSS code is:
overflow: scroll;
-webkit-overflow-scrolling: touch;
Basic AJAX Tutorial: Smooth Scrolling Text Marquee with a jQuery plugin
This tutorial covers:
- What is a plugin?
- Installing a plugin
- The jQuery Marquee plugin
- Implementing the jQuery Marquee plugin
What is a plugin?
A plugin is an addition to the core jQuery functionality. Plugins are made to be simply integrated into an existing jQuery web page.
For this tutorial, we will be working with the jQuery Marquee plugin from remy sharp’s b: log. Take a look, he did a good job putting his post together.
Installing a plugin
Installing plugins is very easy. This is the easiest part of working with all plugins.
Pretty much:
- Download the plugin
- Upload the plugin to your server
- Include the plugin in your document
First, download the jQuery Marquee plugin here (taken from the original post, The Silky Smooth Marquee). If it just displays in your browser, right click on the link and select “Save Link As…”.
Now that we have the plugin, we just need to post it on our site. Upload it to your javascript folder (I normally use “/js” for this).
Finally we need to include the JS library in your document, so we add the following line (into a very basic document):
<html>
<head>
<script language="javascript" src="js/jquery.js"></script>
<script language="javascript" src="js/jquery.marquee.js"></script>
</head>
<body>
</body>
</html>
It’s uploaded!
The jQuery Marquee plugin
Whenever working with a plugin, normally the plugin page has helpful instructions on it’s use, and examples. In this case that is true.
Again, I’m going to link back to the original page — The Silky Smooth Marquee.
On that page the author has detailed:
- Demo
- Download
- Usage
- How it works
- Events
- Support
Very helpful. Additionally, it helps to look and see if there are any useful comments. Usually commenters point out minor flaws in the code posted (or major!), and supply resolutions. If you follow the conversation thread on the post, you will see commenters have requested functionality that was implemented back into the plugin.
Implementing the jQuery Marquee plugin
Now the final part. This is both easy and hard. The easy part is usually getting the basic implementation working. The hard part comes in when you try to do exactly what YOU want to do with THEIR plugin example. Usually it can be done. Sometimes there are minor modifications that have to be made to the original plugin.
Once you have added the library, all you need to do is include the code. There is a great example page, jQuery Marquee Demo, that shows the various implementations.
For our purposes we’ll implement a basic marquee on our page:
<html>
<head>
<script language="javascript" src="js/jquery.js"></script>
<script language="javascript" src="js/jquery.marquee.js"></script>
</head>
<body>
<marquee behavior="scroll" direction="up" scrollamount="1"
height="75" width="150">
<p>This is a test of a Smooth Marquee using jquery.</p>
<p>This is a test of a Smooth Marquee using jquery.</p>
<p>This is a test of a Smooth Marquee using jquery.</p>
</marquee>
</body>
</html>
The plugin automatically binds to the marquee tag. Does yours work? Check out our example of jQuery scrolling text marquee.
That was too easy?
Yes. If you look at the comments, one common request is to adjust the scroll speed. You can see that our scrollamount is already set to the minimum, 1.
The author recommended setting the timeout (refresh rate) to a larger number. By default, it is set to 25ms. If we wanted to go twice as slow, we just have to change that to 50ms. This is where modifying the core code of the plugin comes in. If you want to go ahead and do this:
- Open up the jquery.marquee.js file.
- Find the line: “setTimeout(animateMarquee, 25);”
- Change it to: “setTimeout(animateMarquee, 50);”
- Upload the new jquery.marquee.js file
The sky is the limit.
Please give us feedback on this tutorial, also take some time to thank the author of this plugin, Remy he’d probably appreciate a follow on Twitter, or even a comment on his blog.
Please share, it makes me happy:
Subscribe to Email Alerts
Make a Donation
Popular Posts
Follow Me
Recent Posts
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Johan Brook: Designer and Developer
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Woork
- zupko.info
