The SmoothScroll-effect is made with moo:Smooth Scrolling to Anchors.
When i rebuild the effect with SmoothScroll (Scriptaculous/Prototype) it only scrolls vertically.
Is there a way of expanding the Action SmoothScroll so that is also can scroll horizontally?
The Scriptaculous Effect.ScrollTo doesn’t seem to support horizontal scrolling, because the normal browser behavior of anchors (which it hijacks) does not seem to consider horizontal offset in an absolutely positioned layout. I was able to get the page to jump (not slide) to horizontal offsets with the following script, added to the page through Protaculous.
If I can think of a way to make that transition animate, I’ll post it later on.
Walter
On Nov 19, 2012, at 8:07 AM, JohanW wrote:
The SmoothScroll-effect is made with moo:Smooth Scrolling to Anchors.
When i rebuild the effect with SmoothScroll (Scriptaculous/Prototype) it only scrolls vertically.
Is there a way of expanding the Action SmoothScroll so that is also can scroll horizontally?
Apply the Protaculous Action (latest version). Use the Library picker in the Actions palette to select scriptaculous-packed.
In the top Function Body editor, paste in the following code.
document.on('click', 'a[href]', function(evt, elm){
var target = $$('#' + elm.href.split('#').last()).first();
if( !! target ){
var offsets = target.cumulativeOffset();
var win = document.viewport.getScrollOffsets();
new Effect.Tween(
null,
win[0],
offsets[0],
{},
function(p){ scrollTo(p.round(), win.top);}
);
}
});
This will wire all anchors on this page to scroll sideways. It will ignore vertical scrolling altogether.
Walter
On Nov 19, 2012, at 9:09 AM, Walter Lee Davis wrote:
The Scriptaculous Effect.ScrollTo doesn’t seem to support horizontal scrolling, because the normal browser behavior of anchors (which it hijacks) does not seem to consider horizontal offset in an absolutely positioned layout. I was able to get the page to jump (not slide) to horizontal offsets with the following script, added to the page through Protaculous.
If I can think of a way to make that transition animate, I’ll post it later on.
Walter
On Nov 19, 2012, at 8:07 AM, JohanW wrote:
The SmoothScroll-effect is made with moo:Smooth Scrolling to Anchors.
When i rebuild the effect with SmoothScroll (Scriptaculous/Prototype) it only scrolls vertically.
Is there a way of expanding the Action SmoothScroll so that is also can scroll horizontally?
Aah. You’re using a really old version of Freeway, which doesn’t include the Prototype 1.7 library. You can’t use the script I posted. Here’s one refactored for your version of Prototype:
document.observe('click', function(evt){
var elm = evt.findElement('a[href]');
if(!! elm){
var target = $$('#' + elm.href.split('#').last()).first();
if( !! target ){
var offsets = target.cumulativeOffset();
var win = document.viewport.getScrollOffsets();
new Effect.Tween(
null,
win[0],
offsets[0],
{},
function(p){ scrollTo(p.round(), win.top);}
);
}
}
});
See if that works.
Walter
On Nov 19, 2012, at 11:21 AM, JohanW wrote:
The site now snaps to the anchors.
So Smooth Scrolling doesn’t work anymore?
Yep, I’m still working on a Quick Silver G4.
The hardware stays longer than the software.
I replaced the lines of code.
The horizontal anchors (1 and 2) now sroll smooth.
When anchors 3 and 4 are called, 1 and 2 are still visible.
That depends on how much available screen is to the right of these last anchors. You may need to place an empty HTML box way off to the right to guarantee that you have enough page size to allow scrolling in the largest of browser windows. You cannot anchor right past the end of the page. Try dragging the page any further right with the scroll bar – you’ll find you cannot, unless the browser window is resized down to less than the distance between the furthest right element and the right edge of the page.
Walter
On Nov 20, 2012, at 6:28 AM, JohanW wrote:
Yep, I’m still working on a Quick Silver G4.
The hardware stays longer than the software.
I replaced the lines of code.
The horizontal anchors (1 and 2) now sroll smooth.
When anchors 3 and 4 are called, 1 and 2 are still visible.
About the scrolling-behaviour: The horizontal items seem to limit the vertical ones.
After i placed the HTML box the horizontal positions are improverd.
When i manually scoll from item 1 to item 3 it is possible to get item 3 and 4 automaticly scrolling through the navigation-menu.
But then the scrolling through the navigation-menu to the upper items doesn’t work automaticly.
Moo is probably set to change both horizontal and vertical positions at once. This variant on SmoothScroll has been hand-hacked to only scroll sideways. (The Scriptaculous Effect.ScrollTo is designed to only scroll vertically.) If you’re sure you want both x and y to animate, I can add that.
Walter
On Nov 20, 2012, at 10:26 AM, JohanW wrote:
About the scrolling-behaviour: The horizontal items seem to limit the vertical ones.
After i placed the HTML box the horizontal positions are improverd.
When i manually scoll from item 1 to item 3 it is possible to get item 3 and 4 automaticly scrolling through the navigation-menu.
But then the scrolling through the navigation-menu to the upper items doesn’t work automaticly.
Thanks, it works, you are a genius.
Now there are 6 items to choose from.
It’s going to be a single portfoliosite with different items to visit.This is just the navigation-idea. I hope it’s not going to be to heavy to load.
About the behaviour, i indeed meant choosing X, Y or both (when not needed, it saves some code i think).