|
@@ -110,25 +110,56 @@ $(document).ready(function() {
|
|
"Jump to" functions
|
|
"Jump to" functions
|
|
================================================= */
|
|
================================================= */
|
|
|
|
|
|
|
|
+ var hasScrolledDown = false;
|
|
|
|
+
|
|
|
|
+ function showFixedJumpedTo() {
|
|
|
|
+ // Add classes
|
|
|
|
+ $("div.jump-to-click-area").addClass("jump-to-click-area-toggle");
|
|
|
|
+ $("div.jump-to").addClass("jump-to-toggle");
|
|
|
|
+ $("div.jump-to-list").addClass("jump-to-list-toggle");
|
|
|
|
+ $("img.jump-to-img").addClass("jump-to-img-toggle");
|
|
|
|
+
|
|
|
|
+ // If the user clicks on a link and scrolls up the page, hide list
|
|
|
|
+ $("div.jump-to-list").hide();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function showInitialJumpedTo() {
|
|
|
|
+ // Toggle classes
|
|
|
|
+ $("div.jump-to-click-area").removeClass("jump-to-click-area-toggle");
|
|
|
|
+ $("div.jump-to").removeClass("jump-to-toggle");
|
|
|
|
+ $("div.jump-to-list").removeClass("jump-to-list-toggle");
|
|
|
|
+ $("img.jump-to-img").removeClass("jump-to-img-toggle");
|
|
|
|
+
|
|
|
|
+ // If the user clicks on a link and scrolls up the page, toggle list
|
|
|
|
+ $("div.jump-to-list").show();
|
|
|
|
+ hasScrolledDown = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
// When the user scrolls down, change "position" to "fixed"
|
|
// When the user scrolls down, change "position" to "fixed"
|
|
$(window).scroll(function() {
|
|
$(window).scroll(function() {
|
|
// If the web page is opened on a mobile
|
|
// If the web page is opened on a mobile
|
|
if($(window).width() <= 499) {
|
|
if($(window).width() <= 499) {
|
|
// Declarations
|
|
// Declarations
|
|
var scrollPosition = $(window).scrollTop();
|
|
var scrollPosition = $(window).scrollTop();
|
|
- // var firstFieldPosition = $("div.field_01").offset().top;
|
|
|
|
- var firstItemPosition = $("div.saved-tags").offset().top;
|
|
|
|
|
|
+ var jumpToPosition = $("div.jump-to").offset().top;
|
|
|
|
|
|
- // If the user has scrolled down to the first field
|
|
|
|
- if(scrollPosition >= firstItemPosition) {
|
|
|
|
- $("div.jump-to").css("display", "block");
|
|
|
|
|
|
+ // If the user has scrolled down to "Jump To..."
|
|
|
|
+ if(hasScrolledDown === false && scrollPosition >= jumpToPosition) {
|
|
|
|
+ showFixedJumpedTo();
|
|
|
|
+
|
|
|
|
+ // Update scroll position
|
|
|
|
+ $(window).scrollTop($("div.saved-tags").offset().top - 300);
|
|
|
|
+ hasScrolledDown = true;
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- $("div.jump-to").css("display", "none");
|
|
|
|
|
|
+
|
|
|
|
+ // If the user has scrolled up to the top
|
|
|
|
+ else if(hasScrolledDown === true && scrollPosition === 0) {
|
|
|
|
+ showInitialJumpedTo();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // If the web page is not open on a mobile
|
|
else {
|
|
else {
|
|
- $("div.jump-to").css("display", "none");
|
|
|
|
|
|
+ showInitialJumpedTo();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -140,8 +171,8 @@ $(document).ready(function() {
|
|
// Rotate arrow
|
|
// Rotate arrow
|
|
// $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-180");
|
|
// $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-180");
|
|
// $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-0");
|
|
// $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-0");
|
|
- $(".jump-to img").toggleClass("jump-to-arrow-90");
|
|
|
|
- $(".jump-to img").toggleClass("jump-to-arrow-0");
|
|
|
|
|
|
+ $("img.jump-to-img").toggleClass("jump-to-arrow-90");
|
|
|
|
+ $("img.jump-to-img").toggleClass("jump-to-arrow-0");
|
|
|
|
|
|
return false;
|
|
return false;
|
|
});
|
|
});
|
|
@@ -153,15 +184,6 @@ $(document).ready(function() {
|
|
var chosenFieldPosition;
|
|
var chosenFieldPosition;
|
|
var scrollPositionNew;
|
|
var scrollPositionNew;
|
|
|
|
|
|
- // Toggle the menu
|
|
|
|
- $("div.jump-to div div").slideToggle(300);
|
|
|
|
-
|
|
|
|
- // Rotate arrow
|
|
|
|
- // $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-180");
|
|
|
|
- // $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-0");
|
|
|
|
- $(".jump-to img").toggleClass("jump-to-arrow-90");
|
|
|
|
- $(".jump-to img").toggleClass("jump-to-arrow-0");
|
|
|
|
-
|
|
|
|
// Detect the scroll position of the chosen field
|
|
// Detect the scroll position of the chosen field
|
|
// If the user has chosen the list item 0
|
|
// If the user has chosen the list item 0
|
|
if(chosenLiIndex === 0) {
|
|
if(chosenLiIndex === 0) {
|
|
@@ -176,14 +198,31 @@ $(document).ready(function() {
|
|
chosenFieldPosition = $("div.field_" + chosenLiIndex).offset().top;
|
|
chosenFieldPosition = $("div.field_" + chosenLiIndex).offset().top;
|
|
}
|
|
}
|
|
|
|
|
|
- // Set the new scroll position
|
|
|
|
- // If the user has chosen to jump to "Saved Tags"
|
|
|
|
- if(chosenLiIndex === 0) {
|
|
|
|
- scrollPositionNew = chosenFieldPosition - 14; // 14 // - $("div.jump-to").height() + 38;
|
|
|
|
|
|
+ // If the user hasn't scrolled down
|
|
|
|
+ if(hasScrolledDown === false) {
|
|
|
|
+ console.log(chosenLiIndex);
|
|
|
|
+ // Set the new scroll position
|
|
|
|
+ scrollPositionNew = chosenFieldPosition - $("div.jump-to").height() - 89;
|
|
|
|
+
|
|
|
|
+ // Add classes
|
|
|
|
+ showFixedJumpedTo();
|
|
|
|
+
|
|
|
|
+ // Update scroll position
|
|
|
|
+ hasScrolledDown = true;
|
|
}
|
|
}
|
|
- // If the user has chosen to jump to a category
|
|
|
|
|
|
+ // If the user has scrolled down to "Jump To..."
|
|
else {
|
|
else {
|
|
- scrollPositionNew = chosenFieldPosition - 57; // 77 // - $("div.jump-to").height() - 20;
|
|
|
|
|
|
+ // Set the new scroll position
|
|
|
|
+ scrollPositionNew = chosenFieldPosition - 57;
|
|
|
|
+
|
|
|
|
+ // Toggle the menu
|
|
|
|
+ $("div.jump-to-list").slideToggle(300);
|
|
|
|
+
|
|
|
|
+ // Rotate arrow
|
|
|
|
+ // $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-90");
|
|
|
|
+ // $("div.jump-to span.jump-to-arrow").toggleClass("rotate-arrow-0");
|
|
|
|
+ $("img.jump-to-img").toggleClass("jump-to-arrow-90");
|
|
|
|
+ $("img.jump-to-img").toggleClass("jump-to-arrow-0");
|
|
}
|
|
}
|
|
|
|
|
|
// Apply the new scroll position
|
|
// Apply the new scroll position
|