Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 63 additions and 22 deletions.
  1. +1 −0  .gitignore
  2. +22 −0 package.json
  3. +40 −22 scrollfix.js
View
1  .gitignore
@@ -0,0 +1 @@
+npm-debug.log
View
22 package.json
@@ -0,0 +1,22 @@
+{
+ "name": "scrollfix",
+ "version": "0.0.2",
+ "description": "Small script to fix some of the issues with iOS5's overflow:scroll;",
+ "main": "scrollfix.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Techwraith/ScrollFix.git"
+ },
+ "keywords": [
+ "ios",
+ "browserify",
+ "scroll"
+ ],
+ "author": "joelambert",
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "gitHead": "74730600030512323364fd5572f242583cc1bccb"
+}
View
62 scrollfix.js
@@ -7,25 +7,43 @@
* http://www.opensource.org/licenses/mit-license.php
*/
-var ScrollFix = function(elem) {
- // Variables to track inputs
- var startY, startTopScroll;
-
- elem = elem || document.querySelector(elem);
-
- // If there is no element, then do nothing
- if(!elem)
- return;
-
- // Handle the start of interactions
- elem.addEventListener('touchstart', function(event){
- startY = event.touches[0].pageY;
- startTopScroll = elem.scrollTop;
-
- if(startTopScroll <= 0)
- elem.scrollTop = 1;
-
- if(startTopScroll + elem.offsetHeight >= elem.scrollHeight)
- elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1;
- }, false);
-};
+(function () {
+ var ScrollFix = function(elem) {
+ // Variables to track inputs
+ var startY, startTopScroll;
+
+ elem = elem || document.querySelector(elem);
+
+ // If there is no element, then do nothing
+ if(!elem) {
+ return;
+ }
+
+ // Handle the start of interactions
+ elem.addEventListener('touchstart', function(event){
+ startY = event.touches[0].pageY;
+ startTopScroll = elem.scrollTop;
+
+ if(startTopScroll <= 0) {
+ elem.scrollTop = 1;
+ }
+
+ if(startTopScroll + elem.offsetHeight >= elem.scrollHeight) {
+ elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1;
+ }
+
+ }, false);
+
+ };
+
+ // if we've got a window and we don't have a module
+ // create a global;
+ if ((typeof window != 'undefined') && (typeof module == 'undefined')) {
+ window.ScrollFix = ScrollFix;
+ }
+ // otherwise, export it.
+ else {
+ module.exports = ScrollFix;
+ }
+
+})();

No commit comments for this range

Something went wrong with that request. Please try again.