How to disable scrolling but keep the ability to scroll with an anchor link? - javascript

I am making this site on which I don't want people to be able to scroll with the mouse or the arrow buttons but I want it to be possible to scroll with the anchor links.

On the link provided by #Hugo Sousa you can still scrolling dragging the scroll bar.
You can try using fullPage.js for it using the method $.fn.fullpage.setAllowScrolling(false).
Basically, users won't be able to scroll in the normal way if there's no scroll bar. So this sounds like a good solution for your problem.

Related

Horizontal Scroll on click

Does anybody knows how to implement horizontal scrolling on event? I am trying to replicate this functionality: http://www.spotify-valentines.com/#/home
First, it scrolls fullpage to the right. Then, it scrolls half way to the right. Then it scrolls full page, also to the right, and finally it becomes a normal screen with vertical scrolling.
The site seems to be built with Angular, but I am not sure how this functionality is accomplished.
Thanks!
It can be accomplish by using fullPage.js.
Just create a single section with multiple slides in. Then you can create your custom buttons and associate them with the action $.fn.fullpage.moveTo() or $.fn.fullpage.moveSlideRight() or $.fn.fullpage.moveSlideLeft().

Menu hover effect when scrolling on the page

I created a site with a top navigation bar that has hyperlinks to anchors in the same page for different content.
I'm trying to create a hover effect on the navigation bar when a user scrolls past the corresponding anchor in the same page. For example, when I scroll past link1's anchor, I want the top navigation hyperlink for link1 to change to a different color.
I tried searching Google but can't find anything relevant to do this.
Can someone point me in the right direction or provide some code examples for how I might do this using HTML/CSS/Jquery/Javascript, etc?
Sounds like you want a ScrollSpy plugin.

How to prevent people from scrolling using mouse wheel press our touch dragging?

In HTML/CSS/JS, there is one thing I am having trouble figuring out:
How to prevent people from scrolling an element using the mouse wheel press (i.e. hold down the mouse wheel and drag, or click the mousewheel, drag, click the mouse wheel again) and how to do the same when people try to drag the elements around on a touch-device.
This is something I stumble upon, amongst other places, when trying to make a hamburger-style menu.
Setting an element's CSS to overflow: hidden will hide the scroll bars, but using above two methods, it is still easy to scroll through them.
Until now, the only 'solution' I found was to make a second element, and position it on top of the element that should not be scrollable. But this hardly seems like a perfect solution to me.
How can these events be captured using JavaScript?
How can, on, for instance, this page, scrolling horizontally and vertically be blocked when the menu is open?
If you create a jsfiddle, we can give a better solution. If you are OK with jquery, I can give some solution for your second point "How can, on, for instance, this page, scrolling horizontally and vertically be blocked when the menu is open?".
First you need to create one simple class like below.
.overhidden
{
overflow:hidden !important;
}
Next, we need to apply this class when you press the menu icon on your screen. Also we need to remove if they click again for closing. It is easy to do in jquery like below.
$(document).ready(function(){
$('#hamburger').click(function(){
$('body').toggleClass('overhidden');
});
});

Scroll horizontal with fullPage.js, is it possible with the mouse wheel?

I am using fullPage.js for a one pager website. It works beautifully. It has support for scrolling through full page slides at the flick of the scroll wheel, and each slide can also contain a horizontal slideshow, normally triggered at that point by clicking one of the side arrows.
I want to force the user to scroll through that slideshow before they can progress down to the next slide. Does anyone know of a way to allow the slideshow to be triggered with the mouse wheel when scrolling down? Then when it hits the end of that slideshow it scrolls vertical again to the next slide?
You can do it with jquery.mousewheel like:
$('#fullpage').on('mousewheel', function(event) {
if (event.deltaY > 0){$.fn.fullpage.moveSlideRight();}
else{$.fn.fullpage.moveSlideLeft();}
});
https://github.com/jquery/jquery-mousewheel
Update 2016
Now fullPage.js provides the Scroll Horizontally extension for it.
What you want to accomplish is not that simple to implement in the plugin. Also, I would say forcing the user to follow a path is not consider as a good practice from the user experience point of view.
Also, what should happen once the user reach the next section and then scrolls up? Should he follow all the way back throw the slides of the previous section again in order to keep moving up ?
Anyway, if you want to accomplish it by your own, you would need first of all, to avoid the auto scrolling behavior when scrolling withing your slides (or the section slides for which you want to apply this).
And then, you would need to change the scrolling behavior to trigger the action to go to the next or to the previous slide by triggering the control arrows events depending on the scrolling direction.
Once the end of the slider is reached, you would need to add again the auto scrolling even.
It really doesn't sound simple if you want to do it by your own. You would need to recode the plugin.

How to make div document selected without clicking on it using jquery ? (Auto suggest with Scrolbar)

I am working facing issue in auto suggest with scroll bar. I have to make scroll bar movable on arrow key down, mouse wheel its works fine for me. If I use document keydown event its moving my browser scroll.
I just looking for a functionality with arrow keydown scroll should move. If I click inside the div and try to move scroll bar with arrow keydown its works but if I am not clicking inside div, since document is not clicked scroll bar doesn't work.
I used slimscroll and currently working with enscroll-0.4 plugins but not able to make it fixed. Feel free to ask if you are not clear about my question.
It will be really helpful if anyone have a solution for this issue.

Categories

Resources