Smooth scroll working for navbar, but not other elements (arrows etc)
I have a Rails application that uses a jQuery smooth scrolling function. The smooth scroll works for the navbar links, but not for the 'scroll down' arrow or 'back to top' arrow. I've tried adding a script tag to implement the behavior directly on the element, but no luck. Any recommendations are appreciated!
Here is the scroll function -
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
);
Here is the block containing the down arrow. The parens with (some text here) are not in my actual code, I just changed it for S/O. -
<div class="typebox" style="min-height: 119px;">
<div id="typed-strings">
<h3 class="type-active"><strong style="font-size: 20px; line-height: 1.5em;"> (some text here) <br> (some more text here) <br><br><a href="#web-apps"><%= image_tag "down-arrow.png", class: "down-arrow"%></a></strong></h3>
</div>
<span id="typed"></span>
<br />
</div>
jquery html ruby-on-rails scroll
add a comment |
I have a Rails application that uses a jQuery smooth scrolling function. The smooth scroll works for the navbar links, but not for the 'scroll down' arrow or 'back to top' arrow. I've tried adding a script tag to implement the behavior directly on the element, but no luck. Any recommendations are appreciated!
Here is the scroll function -
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
);
Here is the block containing the down arrow. The parens with (some text here) are not in my actual code, I just changed it for S/O. -
<div class="typebox" style="min-height: 119px;">
<div id="typed-strings">
<h3 class="type-active"><strong style="font-size: 20px; line-height: 1.5em;"> (some text here) <br> (some more text here) <br><br><a href="#web-apps"><%= image_tag "down-arrow.png", class: "down-arrow"%></a></strong></h3>
</div>
<span id="typed"></span>
<br />
</div>
jquery html ruby-on-rails scroll
Is the click triggering the callback? Did you check iftarget
is found on that function? put a breakpoint on the lineif (target.length)
and you can inspect thetarget
variable. Can you create a codepen/jsfiddle to reproduce the problem?
– arieljuod
Nov 10 at 4:45
I'm not super familiar with breakpoints yet, but here's a link to my site. www.justincefai.co
– Justin Cefai
Nov 10 at 23:44
add a comment |
I have a Rails application that uses a jQuery smooth scrolling function. The smooth scroll works for the navbar links, but not for the 'scroll down' arrow or 'back to top' arrow. I've tried adding a script tag to implement the behavior directly on the element, but no luck. Any recommendations are appreciated!
Here is the scroll function -
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
);
Here is the block containing the down arrow. The parens with (some text here) are not in my actual code, I just changed it for S/O. -
<div class="typebox" style="min-height: 119px;">
<div id="typed-strings">
<h3 class="type-active"><strong style="font-size: 20px; line-height: 1.5em;"> (some text here) <br> (some more text here) <br><br><a href="#web-apps"><%= image_tag "down-arrow.png", class: "down-arrow"%></a></strong></h3>
</div>
<span id="typed"></span>
<br />
</div>
jquery html ruby-on-rails scroll
I have a Rails application that uses a jQuery smooth scrolling function. The smooth scroll works for the navbar links, but not for the 'scroll down' arrow or 'back to top' arrow. I've tried adding a script tag to implement the behavior directly on the element, but no luck. Any recommendations are appreciated!
Here is the scroll function -
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
);
Here is the block containing the down arrow. The parens with (some text here) are not in my actual code, I just changed it for S/O. -
<div class="typebox" style="min-height: 119px;">
<div id="typed-strings">
<h3 class="type-active"><strong style="font-size: 20px; line-height: 1.5em;"> (some text here) <br> (some more text here) <br><br><a href="#web-apps"><%= image_tag "down-arrow.png", class: "down-arrow"%></a></strong></h3>
</div>
<span id="typed"></span>
<br />
</div>
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
);
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
);
<div class="typebox" style="min-height: 119px;">
<div id="typed-strings">
<h3 class="type-active"><strong style="font-size: 20px; line-height: 1.5em;"> (some text here) <br> (some more text here) <br><br><a href="#web-apps"><%= image_tag "down-arrow.png", class: "down-arrow"%></a></strong></h3>
</div>
<span id="typed"></span>
<br />
</div>
<div class="typebox" style="min-height: 119px;">
<div id="typed-strings">
<h3 class="type-active"><strong style="font-size: 20px; line-height: 1.5em;"> (some text here) <br> (some more text here) <br><br><a href="#web-apps"><%= image_tag "down-arrow.png", class: "down-arrow"%></a></strong></h3>
</div>
<span id="typed"></span>
<br />
</div>
jquery html ruby-on-rails scroll
jquery html ruby-on-rails scroll
asked Nov 9 at 21:19
Justin Cefai
2617
2617
Is the click triggering the callback? Did you check iftarget
is found on that function? put a breakpoint on the lineif (target.length)
and you can inspect thetarget
variable. Can you create a codepen/jsfiddle to reproduce the problem?
– arieljuod
Nov 10 at 4:45
I'm not super familiar with breakpoints yet, but here's a link to my site. www.justincefai.co
– Justin Cefai
Nov 10 at 23:44
add a comment |
Is the click triggering the callback? Did you check iftarget
is found on that function? put a breakpoint on the lineif (target.length)
and you can inspect thetarget
variable. Can you create a codepen/jsfiddle to reproduce the problem?
– arieljuod
Nov 10 at 4:45
I'm not super familiar with breakpoints yet, but here's a link to my site. www.justincefai.co
– Justin Cefai
Nov 10 at 23:44
Is the click triggering the callback? Did you check if
target
is found on that function? put a breakpoint on the line if (target.length)
and you can inspect the target
variable. Can you create a codepen/jsfiddle to reproduce the problem?– arieljuod
Nov 10 at 4:45
Is the click triggering the callback? Did you check if
target
is found on that function? put a breakpoint on the line if (target.length)
and you can inspect the target
variable. Can you create a codepen/jsfiddle to reproduce the problem?– arieljuod
Nov 10 at 4:45
I'm not super familiar with breakpoints yet, but here's a link to my site. www.justincefai.co
– Justin Cefai
Nov 10 at 23:44
I'm not super familiar with breakpoints yet, but here's a link to my site. www.justincefai.co
– Justin Cefai
Nov 10 at 23:44
add a comment |
1 Answer
1
active
oldest
votes
I cannot find your code on the link, but seeing your website I can think of a few things:
1) your down arrow is not there when you set the click callback, it's added later with that typed effect so the click callback is not set on that A tag. I guess the library you used for that has some event to let you know that the effect is finished, then you can set the callback for that A tag
2) the back to top arrow has href="#"
which is explicittly NOT selected for the click function with the line .not('[href="#"]')
, I'm guessing you copied the function from somewhere else, you can add an id after the href for that back to top A tag and add an element wit that ID at the top of the site
EDIT: to fix the down arrow event listener, I would do this:
1st, move the function outside the parameters
function scroll_to_hash(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(scroll_to_hash);
2nd, I'm guessing you are using Typed.js, you have an onComplete
callback https://mattboldt.com/typed.js/docs/, you can then set the click event for the down arrow on that callback on the options when you initialize the plugin
onComplete: function(self)
$('a[href="#web-apps"]').click(scroll_to_hash)
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Check my last edit.
– arieljuod
Nov 11 at 1:53
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233405%2fsmooth-scroll-working-for-navbar-but-not-other-elements-arrows-etc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I cannot find your code on the link, but seeing your website I can think of a few things:
1) your down arrow is not there when you set the click callback, it's added later with that typed effect so the click callback is not set on that A tag. I guess the library you used for that has some event to let you know that the effect is finished, then you can set the callback for that A tag
2) the back to top arrow has href="#"
which is explicittly NOT selected for the click function with the line .not('[href="#"]')
, I'm guessing you copied the function from somewhere else, you can add an id after the href for that back to top A tag and add an element wit that ID at the top of the site
EDIT: to fix the down arrow event listener, I would do this:
1st, move the function outside the parameters
function scroll_to_hash(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(scroll_to_hash);
2nd, I'm guessing you are using Typed.js, you have an onComplete
callback https://mattboldt.com/typed.js/docs/, you can then set the click event for the down arrow on that callback on the options when you initialize the plugin
onComplete: function(self)
$('a[href="#web-apps"]').click(scroll_to_hash)
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Check my last edit.
– arieljuod
Nov 11 at 1:53
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
|
show 3 more comments
I cannot find your code on the link, but seeing your website I can think of a few things:
1) your down arrow is not there when you set the click callback, it's added later with that typed effect so the click callback is not set on that A tag. I guess the library you used for that has some event to let you know that the effect is finished, then you can set the callback for that A tag
2) the back to top arrow has href="#"
which is explicittly NOT selected for the click function with the line .not('[href="#"]')
, I'm guessing you copied the function from somewhere else, you can add an id after the href for that back to top A tag and add an element wit that ID at the top of the site
EDIT: to fix the down arrow event listener, I would do this:
1st, move the function outside the parameters
function scroll_to_hash(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(scroll_to_hash);
2nd, I'm guessing you are using Typed.js, you have an onComplete
callback https://mattboldt.com/typed.js/docs/, you can then set the click event for the down arrow on that callback on the options when you initialize the plugin
onComplete: function(self)
$('a[href="#web-apps"]').click(scroll_to_hash)
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Check my last edit.
– arieljuod
Nov 11 at 1:53
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
|
show 3 more comments
I cannot find your code on the link, but seeing your website I can think of a few things:
1) your down arrow is not there when you set the click callback, it's added later with that typed effect so the click callback is not set on that A tag. I guess the library you used for that has some event to let you know that the effect is finished, then you can set the callback for that A tag
2) the back to top arrow has href="#"
which is explicittly NOT selected for the click function with the line .not('[href="#"]')
, I'm guessing you copied the function from somewhere else, you can add an id after the href for that back to top A tag and add an element wit that ID at the top of the site
EDIT: to fix the down arrow event listener, I would do this:
1st, move the function outside the parameters
function scroll_to_hash(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(scroll_to_hash);
2nd, I'm guessing you are using Typed.js, you have an onComplete
callback https://mattboldt.com/typed.js/docs/, you can then set the click event for the down arrow on that callback on the options when you initialize the plugin
onComplete: function(self)
$('a[href="#web-apps"]').click(scroll_to_hash)
I cannot find your code on the link, but seeing your website I can think of a few things:
1) your down arrow is not there when you set the click callback, it's added later with that typed effect so the click callback is not set on that A tag. I guess the library you used for that has some event to let you know that the effect is finished, then you can set the callback for that A tag
2) the back to top arrow has href="#"
which is explicittly NOT selected for the click function with the line .not('[href="#"]')
, I'm guessing you copied the function from somewhere else, you can add an id after the href for that back to top A tag and add an element wit that ID at the top of the site
EDIT: to fix the down arrow event listener, I would do this:
1st, move the function outside the parameters
function scroll_to_hash(event)
// On-page links
if (
location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '')
&&
location.hostname == this.hostname
)
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length)
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate(
scrollTop: target.offset().top
, 1000, function()
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) // Checking if the target was focused
return false;
else
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
;
);
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(scroll_to_hash);
2nd, I'm guessing you are using Typed.js, you have an onComplete
callback https://mattboldt.com/typed.js/docs/, you can then set the click event for the down arrow on that callback on the options when you initialize the plugin
onComplete: function(self)
$('a[href="#web-apps"]').click(scroll_to_hash)
edited Nov 11 at 1:53
answered Nov 11 at 0:43
arieljuod
6,26911121
6,26911121
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Check my last edit.
– arieljuod
Nov 11 at 1:53
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
|
show 3 more comments
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Check my last edit.
– arieljuod
Nov 11 at 1:53
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Nice, thanks for that! Super easy fix for the back to top arrow. However, I don't quite follow how I would go about setting the callback for the down arrow.
– Justin Cefai
Nov 11 at 1:45
Check my last edit.
– arieljuod
Nov 11 at 1:53
Check my last edit.
– arieljuod
Nov 11 at 1:53
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
Yeah exactly, it's Typed.js. Ok, so the smooth scroll is working now (thanks!), but the typed.js behavior has stopped working. I'm going to continue to play around with it, but if you have any ideas I'm down to hear them!
– Justin Cefai
Nov 11 at 3:25
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
I found this thread where he seems to be addressing a similar issue, but the fix he recommends gives me the same error I was getting before. github.com/mattboldt/typed.js/issues/341
– Justin Cefai
Nov 11 at 3:53
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
Add your current code to the question, I'm not sure what it looks right now, show the part where you initialize the Typed function.
– arieljuod
Nov 11 at 4:02
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233405%2fsmooth-scroll-working-for-navbar-but-not-other-elements-arrows-etc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is the click triggering the callback? Did you check if
target
is found on that function? put a breakpoint on the lineif (target.length)
and you can inspect thetarget
variable. Can you create a codepen/jsfiddle to reproduce the problem?– arieljuod
Nov 10 at 4:45
I'm not super familiar with breakpoints yet, but here's a link to my site. www.justincefai.co
– Justin Cefai
Nov 10 at 23:44