Smooth scroll for SD3

User 2806889 Photo


Registered User
64 posts

I'm trying to implement the smooth scroll as described in RSD by adding this to the footer section of a page:

<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>

I could not get this to work in SD3. It's almost like anything I add to the head (back to top script) or footer (smooth scroll) section in the Manage Project section doesn't have any effect-with the exception of the Responsive Content Slider. Here's a link...http://hurtclan.myds.me/test. What am I doing wrong here?
User 283347 Photo


Registered User
388 posts

I'm not where I can look for sure, but I think you have give a class name of scroll... Or smooth scroll.... Possibly both?
User 122279 Photo


Senior Advisor
14,450 posts

https://css-tricks.com/snippets/jquery/ … scrolling/
This is a link to various ways of creating smooth scrolling, from easy to complicated. ;) Maybe if you try them out...

Edit: The easiest way, just this bit of css:
html {
scroll-behavior: smooth;
}

works fine in Ffx, Chrome and Opera plus some Android browsers, but is not supported by anything M$ nor Safari.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 2806889 Photo


Registered User
64 posts

I will look at that Mark. Thanks.

Inger, The workaround that I found successful was adding a css file with "html {scroll-behavior: smooth;}". That is the first option in the link you sent. That does work great. I'm still trying to get the back to top working. In RSD, I used the thread https://www.coffeecup.com/forums/responsive-site-designer/scroll-to-top-button/ to make it work. There must be something I'm missing with SD3.

I guess the crux of my question is what's different about the header and footer sections when working with SD3 than it was with RSD?
User 122279 Photo


Senior Advisor
14,450 posts

Jeff, it seems to me that you were after the 'scroll to top' feature, not 'smooth scroll'. In the discussion you referred to there is a link to a viola site with scroll to top, but the scrolling is not smooth on that site.

BTW, I like those two quotations at the bottom of your site! They are as true today as they were when first spoken!
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 2806889 Photo


Registered User
64 posts

Inger,

I updated the site to include the css "html {scroll-behavior: smooth;}". So that the smooth scroll does work. The back-to-top that was used in RSD does not work. My big question is what's different about adding scripts to the header and footer in RSD and SD3?
User 122279 Photo


Senior Advisor
14,450 posts

I noticed you had added that scroll behaviour. It works for me in Ffx and Chrome, but not in IE and Edge.

I have no idea what the differences between RSD and SD3 might be in this respect. I'll look into it...

Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 2699991 Photo


Registered User
4,799 posts
Online Now

Inger wrote:
I noticed you had added that scroll behaviour. It works for me in Ffx and Chrome, but not in IE and Edge.

I have no idea what the differences between RSD and SD3 might be in this respect. I'll look into it...



So what's wrong with adding the attribute "data-smooth-scroll" (value = ID of target element)
Mastering The Understanding With Hands-On Learning
NEW TO "COFFEECUP SITE DESIGNER" FOUNDATION 6 FRAMEWORK?
STUCK ON SOMETHING?

LEARNING & UNDERSTANDING "THE HOW TO"? THE WHY'S & THE WHEREFORE'S?
WITH WAYAN'S STEP BY STEP TUTORIALS
Contact Me For One To One Assistance
https://alphathemes.coffeecup.com/forms … an%281%29/
User 122279 Photo


Senior Advisor
14,450 posts

Jeff, I didn't have any problem making this scroll to top work in Sd3. I used Steve's code and script right out of the box (plus the icon Jamie provided). I did one thing differently, though, I pasted the css into the head section of the SD3 file, just because I found it more convenient. Have a look. The file is otherwise totally empty. It seems that the scroll to top thingie has a smooth scroll built in BTW. And it's working in IE11 and Edge.

Wayan, I don't know if there is anything wrong with using the attribute you mention, I haven't tried, haven't thought that far yet ;)
Attachments:
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 122279 Photo


Senior Advisor
14,450 posts

Yep, Wayan, works! Also in the M$ browsers. :)
I didn't even know there was such an attribute...
Attachments:
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.