Skip to content

Commit

Permalink
nav anchor scroll bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
runrog committed Jun 1, 2020
1 parent 37d8e88 commit 55710d5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/js/picazzo.bundle.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions dist/js/picazzo.droplet.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -4561,11 +4561,13 @@ window.drzzle = {
$.fn.drzAnchorScroll = function anchorScroll() {
var $this = $(this);
var scrollTo = function scrollTo(e) {
var name = $(this.hash).selector.split('#')[1];
var $el = $('[data-anchor-scroll="' + name + '"]');
if (_typeof($el.offset()) !== (typeof undefined === 'undefined' ? 'undefined' : _typeof(undefined)) && $el.offset() !== false) {
e.preventDefault();
$('html, body').animate({ scrollTop: $el.offset().top }, 500);
if (this.hash !== '#/cart') {
var name = $(this.hash).selector.split('#')[1];
var $el = $('[data-anchor-scroll="' + name + '"]');
if (_typeof($el.offset()) !== (typeof undefined === 'undefined' ? 'undefined' : _typeof(undefined)) && $el.offset() !== false) {
e.preventDefault();
$('html, body').animate({ scrollTop: $el.offset().top }, 500);
}
}
};
$this.find('a').click(scrollTo);
Expand Down
2 changes: 1 addition & 1 deletion dist/js/picazzo.droplet.lib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/tools/scrolling.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"build:icons": "gulp build-icons",
"deploy:docs": "./scripts/deploy-docs.sh",
"deploy:lib:dev": "./scripts/deploy-lib.sh",
"deploy:lib:prod": "./scripts/deploy-lib.sh prod"
"deploy:lib:prod": "./scripts/deploy-lib.sh prod",
"postversion": "git push && git push --tags"
},
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion src/droplets/navigation/template.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div class="drzNav drzNav-links-right" data-nav-slide="left" ref="navigation">
<button class="drzNav-hamburger"></button>
<a href="#">
<div class="drzNav-logo drzNav-logo-left">
<!-- <img here> -->
</div>
</a>
<a class="drzNav-cart" href="#/cart" name="cart">
<span class="drzNav-cart-count">(1)</span>
</a>
Expand All @@ -13,7 +18,6 @@
</div>
</div>
</div>
<a href="#"><div class="drzNav-logo drzNav-logo-left"></div></a>
<ul class="drzNav-list">
<li class="drzNav-item"><a href="#" class="drzNav-link drzNav-link-dropDown">DD Link</a>
<ul class="drzNav-subList">
Expand Down
1 change: 0 additions & 1 deletion src/js-lib/picazzo.global.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ window.drzzle = {
};
})(jQuery);


/* Url checker for hashed links
* ======================= */
(($) => {
Expand Down
12 changes: 7 additions & 5 deletions src/tools/scrolling/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
$.fn.drzAnchorScroll = function anchorScroll() {
const $this = $(this);
const scrollTo = function scrollTo(e) {
const name = $(this.hash).selector.split('#')[1];
const $el = $(`[data-anchor-scroll="${name}"]`);
if (typeof $el.offset() !== typeof undefined && $el.offset() !== false) {
e.preventDefault();
$('html, body').animate({ scrollTop: $el.offset().top }, 500);
if (this.hash !== '#/cart') {
const name = $(this.hash).selector.split('#')[1];
const $el = $(`[data-anchor-scroll="${name}"]`);
if (typeof $el.offset() !== typeof undefined && $el.offset() !== false) {
e.preventDefault();
$('html, body').animate({ scrollTop: $el.offset().top }, 500);
}
}
};
$this.find('a').click(scrollTo);
Expand Down

0 comments on commit 55710d5

Please sign in to comment.