Title: JavaScript error on edge cases
Last modified: April 2, 2020

---

# JavaScript error on edge cases

 *  Resolved [jphilung](https://wordpress.org/support/users/jphilung/)
 * (@jphilung)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/)
 * There’s an edge case where the plugin conflicts with previews of forms in Ninja
   Forms as the preview uses the home page to display the preview. Should the homepage
   contain the shortcode, the js is enqueued but will fail as Ninja Forms does not
   display the content of the home page.
 * The fix would entail changing the code in dd-parallax-offset.js in order to check
   for the existance of $(‘.parallax-section, .parallax-mobile’).
 * For example :
 *     ```
       jQuery(document).ready(function ($) {
           var parallaxSection = $('.parallax-section, .parallax-mobile');
           if (parallaxSection.length != 0) {
               var pxcontentOffset = parallaxSection.offset().left;
               $('.parallax-content').css('left', '-' + pxcontentOffset + 'px');
               $(".px-mobile-container").each(function () {
                   var i = $(this).attr("data-factor") * $(window).width();
                   $(this).css("height", i + "px")
               })
           }
       });
       ```
   

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [thehowarde](https://wordpress.org/support/users/thehowarde/)
 * (@thehowarde)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/#post-12616640)
 * I will review this.
 *  Plugin Author [thehowarde](https://wordpress.org/support/users/thehowarde/)
 * (@thehowarde)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/#post-12664101)
 * Are you using the offset? The offset script is only enqueued if `offset="true"`
   is set.
 *  Thread Starter [jphilung](https://wordpress.org/support/users/jphilung/)
 * (@jphilung)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/#post-12668198)
 * Yeah, the offset is used. The problem arises because the Ninja Forms preview 
   uses the page content for the homepage, but removes the content. The content 
   has the shortcode and thus Parallax Image enqueues the script and fails on the
   non existing parallax section. It’s better to check for existence in the js.
 *  Plugin Author [thehowarde](https://wordpress.org/support/users/thehowarde/)
 * (@thehowarde)
 * [6 years ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/#post-12768436)
 * This has been implemented.
 *  Thread Starter [jphilung](https://wordpress.org/support/users/jphilung/)
 * (@jphilung)
 * [6 years ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/#post-12781321)
 * Great !

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘JavaScript error on edge cases’ is closed to new replies.

 * ![](https://ps.w.org/parallax-image/assets/icon-128x128.png?rev=1627242)
 * [Parallax Image](https://wordpress.org/plugins/parallax-image/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/parallax-image/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/parallax-image/)
 * [Active Topics](https://wordpress.org/support/plugin/parallax-image/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/parallax-image/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/parallax-image/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [jphilung](https://wordpress.org/support/users/jphilung/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/javascript-error-on-edge-cases/#post-12781321)
 * Status: resolved