Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. custom js question

custom js question

Scheduled Pinned Locked Moved General Discussion
4 Posts 2 Posters 87 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DLB
    wrote on last edited by
    #1

    Hey Armin,

    I’m working on some updates to a site, I’ve added a footer for one particular page which has some text positioned in the bottom right corner, which acts as ‘close’ (back to previous page) button.

    I‘ve added some JS in the ‘Custom CSS & HTML’ section, which makes the footer ‘close’ text appear after you have scrolled 75% of the page. However there appears to be a ‘bug’ with my code, as the ‘close’ text appears as soon as the page loads, but disappears as soon as you start scrolling, but then appears as it should do after 75% of the page is scrolled. Is there a way I can make the ‘close’ text not appear on page load (or on a page refresh)? I guess I must have missed something with the code?!

    Thanks, D

    url: https://www.helenfelcey.co.uk/info-and-contact/

    js:

    	jQuery(document).scroll(function() {
    		var scrollPercent = 100 * jQuery(window).scrollTop() / (jQuery(document).height() - jQuery(window).height());
    		if (scrollPercent > 75) {
    			jQuery('#footer-region').fadeIn();
    		} else {
    			jQuery('#footer-region').fadeOut();
    		}});
    </script>
    1 Reply Last reply
    0
    • arminunruhA Online
      arminunruhA Online
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #2
      function myscroll() {
      	var scrollPercent = 100 * window.scrollY / (jQuery(document).height() - jQuery(window).height());
      	if (scrollPercent > 75) {
      		jQuery('#footer-region').fadeIn();
      	} else {
      		jQuery('#footer-region').fadeOut();
      	}
      }
      
      window.laytheme.on("newpageshown", function(){
      	jQuery(document).on('scroll', myscroll);
      })
      
      window.laytheme.on('before_content_replacement', function(){
      	jQuery(document).off('scroll', myscroll);
      })
      

      does this work maybe?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DLB
        wrote on last edited by
        #3

        Thanks for looking into this @arminunruh – still getting the same issue as before with the new code, unfortunately. The footer text still appears on page load (and when refreshed). Any thoughts?

        1 Reply Last reply
        0
        • arminunruhA Online
          arminunruhA Online
          arminunruh
          Global Moderator
          wrote on last edited by arminunruh
          #4

          oh yea so the text needs to be hidden by default

          you can use css to have it hidden at the start

          in lay options → custom css & html → custom css:

          #footer-region{
          opacity: 0;
          }
          
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          I also code custom websites or custom Lay features.
          💿 Email me here: 💿
          info@laytheme.com

          Before you post:
          1. When using a WordPress Cache plugin, disable it or clear your cache.
          2. Update Lay Theme and all Lay Theme Addons
          3. Disable all Plugins
          4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

          This often solves issues you might run into

          When you post:
          1. Post a link to where the problem is
          2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
          3. If the problem is difficult to explain, post screenshots / link to a video to explain it
          Online Users
          arminunruhA
          arminunruh
          F
          francesco
          L
          lurchifon
          Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
          laytheme.com
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search