I'm creating my web-page by using fullpageJs https://alvarotrigo.com/fullPage/ plugin, and trying to make accordion FAQ page.
Basically the accordion refers to https://bootsnipp.com/snippets/QXdqR
The problem is when accordion exceeds the page height, the scrollbar doesn't work properly. (I'm activating "scrollOverflow" option)
Here is my current jQuery:
$(document).ready(function() {
$('.accordion').find('.accordion-toggle').click(function() {
$(this).next().slideToggle('600');
$(".accordion-content").not($(this).next()).slideUp('600');
});
$('.accordion-toggle').on('click', function() {
$.fn.fullpage.reBuild();
$(this).toggleClass('active').siblings().removeClass('active');
});
});
I just added $.fn.fullpage.reBuild();, trying to solve the problem.
However, I'm still stucking with three problems below;
It works only when the scrollbar is originally shown in the screen. (When "Q" content exceeds the height of screen)
Whole accordion move to unpredicted position after opening & closing answer.
(This happens when scrollbar originally isn’t displayed on the screen and then exceeds the height when the accordion opens. (This is hard to explain in words, and I hope the explanation makes sense…))
It seems adding $.fn.fullpage.reBuild(); makes the page slow to load. (especially on mobile). Is there any way to solve this?
By the way, I could get an ideal result when I resized browser each time after opening & closing answers.
...That’s it.
I would appreciate it very much if someone taught me any suggestions.
Try this:
$('#fullpage').fullpage({
scrollOverflow: true
});
Related
First of all, I really do not know how to describe my problem. So, I ask you to check my JSFiddle Code Playground at the beginning.
https://jsfiddle.net/coming123/q46tjuev/
To see the problem, I want you to run this playground with a low width. Then, click to the "navbar-toggler" on the top left, which is provided by Bootstrap4's itself and a little bit desiged by me. When you click it, the navbar will be appeared from top to bottom on the right side. The problem appears at this point.
This navbar make the background became higher and makes the other contents move to bottom side. Scroll the page and you will see a bug appeared. background became higher but the parallax effect has been broken. Now you should make the area resized by pulling or pushing from sides. Just a little resizing will make this bug fixed. What I afraid is on mobile phones, you can not resize the browser. So the bug will not be fixed. Also I do not want it to be fixed by this way. I did not get why this problem appears.
I tried to make the div reloaded when you click the navbar-toggler but nothing has been fixed.
document.querySelector("button").addEventListener("click", () => {
var container = document.getElementsByClassName("top");
var content = container.innerHTML;
container.innerHTML= content;
console.log("Done");
});
Any suggestion?
I am doing an website where I have to keep one image fixed to the screen and on scroll I want different elements to appear one by one and stick to one position. When this is done I continue to the footer of the website.
I have done tried to reach that but whatever I do the page keeps scrolling and does not wait for all the elements to appear on the screen.
Example of what I want to do can be seen here Link on the second page where the mobile phone it is sticked in the screen and on scroll different content appear one by one.
How do I achieve this ? What kind of libraries would you suggest?
Thank you in advance.
stuff like this is usually done with js libriaries, as you already wrote. One that is actively supported and works quite well is Scrollmagic. It should be able to do what you describe, at least it can do the stuff in the example you linked: It can "pin" elements on the page for a defined duration (= "scroll duration") or animate elements controlled by the scroll position.
Scrollmagic can be found on Github or here: http://scrollmagic.io/ , examples to be seen here: http://scrollmagic.io/examples/index.html
Your fixed html content should have css position: fixed;.
Have you tried position: sticky? There may be browser compatibility issues but there are polyfils out there to fix that.
Please take a look at this site: removed per request
When you click Learn More, the Fancybox lightbox window pops up and looks fine, but when you click the right arrow on the lightbox, a scrollbar shows up for just an instant (it reaches all the way to the top of the doctor's picture). This is happening on Chrome and Safari.
I can't figure out what code to write to not show that scrollbar. The content will never be long enough to need a scrollbar (except on mobile, etc). Another option would be to just have the scrollbar stop at the top of the content container (not go all the way up to the top of the dr's picture). Please help if you can; it would be much appreciated!! I'm a newb to jQuery/Javascript. Thank you!!
You can try to solve this with CSS. Set overflow: hidden on the container div. This will hide any content that overflows the container, so use with care.
I'm trying to find the best technique for showing a navigation/menu for a mobile site I'm working on. So far all my solutions have flaws, and I was wondering if anyone could point me in the right direction. (You may have to reduce browser window size to make the examples work as intended)
First off, take a look at this "basic" example: http://audunaas.no/menu/problem.html
You'll notice the content is still scrollable while the navigation is open. This is confusing and annoying.
My first attempt at a fix was to set the body to overflow:hidden and position:fixed whenever the navigation is open. Example here: (Had to remove link because maximum 2 links in post)
This, however, causes the body to snap back to the top and "forget" its scroll position. This means you are taken back to the top of the page whenever you open the navigation. Not good.
Lastly, my best solution so far is one where i put all the page content inside a #scroll-area-div with a fixed position taking up most of the screen, and body scroll set to hidden. Example here: http://audunaas.no/menu/
This solves most of the problems in the page itself, but breaks the "memory" of the back button. This means whenever you click back in your browser you are taken to the top of the page instead of back to where you were before you decided to click a link. (Mobile safari seems to be the only browser that remembers scroll position on div's aswell as body)
I can't really think of any more solutions to this, except for maybe some sort of javascript. Does anyone have some experience with similar cases, or any ideas on how to accomplish this?
The solution must:
Prevent scrolling on page content when navigation is open
Preserve scroll position on page content when navigation is open
Remember scroll position on previous page when back-button is used
I am currently designing a webpage that is extremely vertical, my idea was that users would not scroll around the page, but only when they clicked on links with internal anchors (href="#someDiv"), the page would automatically scroll down to that section.
So that the elements of the page are organized into bundles, and the user clicks to go up or down to one section of the single page or another.
I've uploaded the page to the following url:
DWS - Prototype
The page is fairly straightforward, and I am using a smooth-scroll jQuery plugin for the automatic scrolling. All I want is for the user to not be able to wander about on his/her own.
I have tried using overflow:hidden, and looked for javascript or jQuery to get this done, but can't seem to find a viable solution. Overflow hidden prevents the page from loading past the screen, so you can't link to the other elements of the page.
I haven't really tested the HTML/CSS beyond Mac OS, but it works fine on Safari, Firefox and Chrome.
You can disable the scroll bar on a page using the following css property
body{overflow: hidden;}
This will disable both the scroll bar and the mousewheel (im not sure about Pg Up and Down Buttons)
While you definitely have an interesting concept I think it will be very hard to pull off the way you're wanting. What happens if I have the height of my browser window set so small that I can't see your Navigation menus and I also can't scroll? Chances are I'm just gonna get fed up with your site and leave.
When users see a vertical scrollbar they expect to be able to scroll up and down. Taking that way from users is more likely to frustrate and anger them as opposed to them thinking 'This is really cool'.
That being said you could load up jQuery and do something like this:
$(document).ready(function() {
$('html, body').scroll(function(e) {
e.preventDefault();
});
});
This should prevent the scrollbar from going up or down. disclaimer: I have not tested this.
I suggest you make the sections (partially) collapsible. E.g. like here.