automattic / antiscroll Goto Github PK
View Code? Open in Web Editor NEWOS X Lion style cross-browser native scrolling on the web that gets out of the way.
OS X Lion style cross-browser native scrolling on the web that gets out of the way.
See this screenshot. That tiny little black thing at the right side is antiscroll.
A simple fix is to add a minimal height, and adjust the top position based on it:
// Scrollbar.Vertical.prototype.update
height = trackHeight * paneHeight / innerEl.scrollHeight
top = trackHeight * innerEl.scrollTop / innerEl.scrollHeight
if height < 30
top = top - (30 - height)
height = 30
this.el
.css('height', height)
.css('top', top)
Minimum height should probably be an option, as well.
This is a great scrolling plugin! However I have stumbled across a small issue.
Say I am appending content like chat and there isn't quite enough content in the div yet when it reaches the point there is enough content the scroll bar doesn't appear but however the scroll mechanisms are fine! Its just the UI isn't retained.
I was trying to set it up with 100% width & height elements but it's not working, so I tried to dynamically set the width and height through javascript, it works this way but the div native scrollbars still appear, see image attached
HTML behind is:
<body>
<div class="box-wrap antiscroll-wrap">
<div class="box">
<div class="antiscroll-inner">
<div class="box-inner">
...
</div>
</div>
</div>
</div>
</body>
The CSS:
body {
padding: 0;
margin: 0;
overflow: hidden;
}
The JS:
$(window).on('load resize', function() {
$('.antiscroll-inner').css({
height: $(window).height(),
width: $(window).width(),
});
}).resize();
This will improve scrollbar animation performance with content-heavy elements. Facebook's ticker suffers from this.
Steal the feature detection from modernizr for it (if it has one)
Hi,
This is a small fix for elements that appear on run-time (ie. onclick of a button) and their content changes. Since they have display hidden initially I had to call .antiscroll() every time I show an element, in order to reset the scroll bars (I don't know if there is a better way of doing this...).
Now this causes constant size expansion each time the element appears (due to the css width += scrollbarSize() in the initialization function). My solution was to remove this extra width/height in the destroy():
Antiscroll.prototype.destroy = function () {
this.inner.css({
'width': '-=' + (this.y ? scrollbarSize() : 0)
, 'height': '-=' + (this.x ? scrollbarSize() : 0)
});
if (this.horizontal) {
this.horizontal.destroy();
this.horizontal = null
}
if (this.vertical) {
this.vertical.destroy();
this.vertical = null
}
return this;
};
Please let me know if I am doing something wrong, but seems reasonable to me to add this code in destroy, just to leave the element in its original state. This will also solve problems when antiscroll() is called multiple times.
Andreas
Okay so not really an issue, just a public service announcement from The Curator, David Higgins (@Higgo)
-- This repo has been included in The Github Pirates' Chest.
What is this about?
The Github Pirates is a constantly updated resource for those interested in HTML5, CSS3, and JavaScript.
You should find out more about this project below:
OR, Download The Chest:
Is this still maintained? Is a stable release planned?
Hi, I'm trying the lib (look great) but I can't scroll up! Only down. I'm on Chrome 22 beta for Mac OS X. Also, I'm using it like it's on the demo page.
Please let me know if you need further info.
Cheers.
Some tags would be very welcome as it would ease locking dependencies.
...it points to https://github.com/learnboost/antiscroll/downloads.
i think the scrollbars need to be updated when the window resizes and when the inner content grows.
When I change the overflow-{x,y} attribute from auto to hidden after antiscroll construction
The antiscroll scroll bar still show on mouse over, scroll, etc.
I think it should be hidden like native scroll bar
Hi there,
I like your plugin pretty much but it would be nice if you create an intial version (v1.0
) on GitHub, so that I can use your plugin with a specific version, so that my application doesn't break if you change your plugin.
Your plugin is also listed on http://bower.io/search/ so it would be nice if you add a bower.json
configuration file. I can help you with that! :)
Cheers from Berlin,
Benny
can somebody update the mousewheel library to latest version?
The scrollbar estimation function doesn't work for me (Chrome for OSX 10.7.5)
Here's the fix:
var w1 = $('div', div).innerWidth();
div.css('overflow-y', 'scroll');
// huyl: fix this function (doesn't work on chrome for mac at least)
// as per http://stackoverflow.com/a/10692895/161972
//var w2 = $('div', div).innerWidth();
var w2 = $('<div>').appendTo($('div', div)).width();
would it be plausible to do the bounce at the end of the content? for example how Safari bounces if you reach the edge of the page and keep trying to scroll via trackpad/mousewheel.
please add it to npm so projects can depend on it nicely.
On Mac, we have very nice.. no, we have world-class trackpads and inertial scrolling.
On Windows, scrolling isn't too hot. So I think it'd be best to maintain scroll up/down buttons for them. They are butt-ugly, so it'd be good to have something that looked better.
The scrollbar appears but does not respond to anything. I could not put it on the div that is under the Filter space.
Take a look on my example
When .anitscroll()
is first called, the scrollbars are visible on the <div>
until you hover the mouse over the div and back out.
Hi!
On Firefox 28.0 on OS X I get two vertical scrollls. I could not find what's wrong. Any Clue?
Works fine on Chrome and Safari too.
here is the example URL : http://www.pannel.cl/page-hacemos-stands.php
Thanks fot your help
During the scroll bar size calculation the test div element with 50x50px is temporary created. But from some page scale (50%) this isn't enough for scrollbars (or scroll buttons, I'm not sure) and this function returns size 0.
Suppose that larger div should used (in my case it was 200x200).
Hi
I've tried setting initialDisplay, and also tried manually triggering scroll(), mouseenter(), mousewheel() and a bunch of other hacks, but I just can't seem to make the scrollbar appear immediately. I can make the scrollbar appear on mouseover of the element (a popup menu - see the "Choose Your Daddy-O" menu here in bottom left of screen http://campaigns.myer.com.au/FathersDay). But I can't seem to trigger it to auto-show as soon as the menu appears.
Any help appreciated. Cheers
Jason
Is it possible to scroll to a specified point inside the antiscroll component, maybe with a keypress?
RTL browsers (Hebrew, Arabic) will place the scrollbar in the left side of the element.
In Lion when you mouseover the scrollbar,the track background will be show and you can click it to up or down scroll the page.
Sorry but i don't know whether it is called this name,do you know my words about the "track background"?
See the result here : http://i.imgur.com/e3ah4.png
Moving the antiscroll scrollbar works and move the original IE scrollbar.
why does not the plugin autowrap the elements ?
Hi,
My container is 100% height. I am handling the window resize to update the scroller. All three potential methods I've tried have issues.
Here is a gist that demonstrates the issue.
https://gist.github.com/2522897
The methods I've tried to get this to work
I'm not sure why the plugin has both a rebuild and a refresh method? From reading the previous issues it seems rebuild was meant to solve the issue of flexible containers. I have an alternative fix which doesn't require the rebuild method.
function Antiscroll (el, opts) {
this.el = $(el);
this.options = opts || {};
this.x = false !== this.options.x;
this.y = false !== this.options.y;
this.padding = undefined == this.options.padding ? 2 : this.options.padding;
this.inner = this.el.find('.antiscroll-inner');
this.refresh();
};
Antiscroll.prototype.refresh = function() {
var width = this.el.width(),
height = this.el.height(),
needHScroll, needVScroll;
this.inner.css({
'width': (width + scrollbarSize()) + 'px'
, 'height': (height + scrollbarSize()) + 'px'
});
needHScroll = this.inner.get(0).scrollWidth > width;
needVScroll = this.inner.get(0).scrollHeight > height;
if (!this.horizontal && needHScroll && this.x) {
this.horizontal = new Scrollbar.Horizontal(this);
} else if (this.horizontal && !needHScroll) {
this.horizontal.destroy();
this.horizontal = null
}
if (!this.vertical && needVScroll && this.y) {
this.vertical = new Scrollbar.Vertical(this);
} else if (this.vertical && !needVScroll) {
this.vertical.destroy();
this.vertical = null
}
};
I simply update the inner size in the refresh method. This step can then be removed from the constructor. Works great for me. Maybe I am missing the reason for the rebuild method.
Thanks
Throws a JS error:
Uncaught TypeError: Object [object Object] has no method 'antiscroll'
Demo link http://learnboost.github.io/antiscroll/ - 404
Example:
http://fonbet.asm0dey.cloudbees.net/
Just resize browser window to size, when table doesn't fit into screen (by height).
Is it possible for the scroll bar to appear on the top (or both top & bottom) of the rendered table? It might be handy if it's a large table and the user needs to be clued in that there are more columns to the right.
Bryan
If false
, don't show automatically
If true
, show and hide after 3000ms
If Number
, show and hide after ms
I think antiscroll not user friendly (in codding)
Check my fork plz
Demo : http://jsbin.com/usequl/4/edit
What do you think about it ?
My Fork : https://github.com/AliMD/1scroll/
Would adding click support on scrollbar areas (outside the scroll handles, but inside the invisible scroll axes) be considered for paging? Having this feature would make the replacement scrollbars on par with the native scrollbars.
I'm just wondering if the lack of click support is by design, or something that can be considered if someone is willing to do it.
On my answer about Antiscroll on Stack Overflow (http://stackoverflow.com/a/12658668/507629), I have been notified that the native scrollbar shows underneath the Antiscroll scrollbar. I just checked on the demo page and the native scrollbar is showing. I'm using Chrome 26 on Mac OS X (Mountain Lion).
We at VersionEye are working hard to keep up the quality of the bower's registry.
We just finished our initial analysis of the quality of the Bower.io registry:
7530 - registered packages, 224 of them doesnt exists anymore;
We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).
Sadly, your library LearnBoost/antiscroll
is one of them.
Can you spare 15 minutes to help us to make Bower better?
Just add a new file bower.json
and change attributes.
{
"name": "LearnBoost/antiscroll",
"version": "1.0.0",
"main": "path/to/main.css",
"description": "please add it",
"license": "Eclipse",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"<dependency_name>": "<semantic_version>",
"<dependency_name>": "<Local_folder>",
"<dependency_name>": "<package>"
},
"devDependencies": {
"<test-framework-name>": "<version>"
}
}
Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.
NB! Please validate your bower.json with jsonlint before commiting your updates.
Thank you!
Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!
Looks like the latest Chrome update has something funny going on with hiding native scrollbars. See screenshot - you get the custom antiscroll scrollbar overlaid on top of the native one. Screenshot is from Chrome 25.0.1364.99.
A co-worker has 24.0.1312.56 and this problem doesn't occur.
Related to issue #40 and the fix proposed in that commit, but the fix doesn't work on Lion.
Hey,
On Mac OS X with Chrome there's a rounding error when trying to stop the window from scrolling when reaching the end of the antiscroll box.
> log y, this.innerEl.scrollTop, this.pane.el.height(), this.innerEl.scrollHeight
-0.025 585 299.77777767181396 885
The mousewheel end detection is this:
if ((y > 0 && 0 == this.innerEl.scrollTop) ||
(y < 0 && (this.innerEl.scrollTop + this.pane.el.height()
== this.innerEl.scrollHeight))) {
ev.preventDefault();
return false;
}
A simple fix for the rounding error:
((y > 0 && 0 == this.innerEl.scrollTop) ||
(y < 0 && (1+this.innerEl.scrollTop + this.pane.el.height()
>= this.innerEl.scrollHeight)))
or:
((y > 0 && 0 == this.innerEl.scrollTop) ||
(y < 0 && (this.innerEl.scrollTop + Math.round(this.pane.el.height())
>= this.innerEl.scrollHeight)))
This applies to both horizontal and vertical scroll.
README explains how it works but not actual usage.
How do you even set it up and invoke it?
I've been trying to get OSX Lion styled scrollbars to replace the default OS scrollbars for an iframe. I couldn't get this plugin to work with the iframe though. Has anyone else successfully done this?
It looks as though the following has no more affect in OSX Yosemite - the default scrollbar shimmers below the custom bar.
.antiscroll-inner::-webkit-scrollbar,
.antiscroll-inner::scrollbar
width: 0
height: 0
display: none
HI,
The plugin doesn't seem to work with jQuery 1.10.2. I get a 'Uncaught TypeError: Object # has no method 'createDocumentFragment' error.
I am using the script in Wordpress 3.6 Any ideas what could be the problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.