vue-scrollto not lining up on mobile - offset for mobile only?










0















I'm using the wonderful vue-scrollto along with bootstrap. It's working great and lands perfectly when viewed on the desktop. On mobile however, the heading is off the top. I know from previous experience with dynamic scrolling that padding the header is the way to go, which works on one section in my site but not on another.



I thought perhaps it was because I'm loading content dynamically and adding content to the dom, but doesn't seem to be the issue since other, static sections have the same issue. It does seem to be when a content section is taller than the viewport. I was originally targeting the id of the container for the section but changed it to the id of the heading with no change.



If I add offset it can help but inconsistently - works on the about section but the locations section is still way off. I figured it would just scroll the top of the container i'm targeting to the top of the page, but that doesn't seem to be what's happening.



Example link:



 <li class="nav-item">
<a class="nav-link nav-btn" href="#" v-scroll-to="'#title-about'" data-toggle="collapse">About</a>
</li>


In my app.js:



Vue.use(VueScrollTo, 
container: "body",
offset: -100
)


You can see it in action here: lovelaundry



It seems as though any section that is taller than the viewport doesn't land right - like it positions in the vertical center rather than scrolling to place the top of the targeted element at the top of the viewport, which would be ideal.










share|improve this question




























    0















    I'm using the wonderful vue-scrollto along with bootstrap. It's working great and lands perfectly when viewed on the desktop. On mobile however, the heading is off the top. I know from previous experience with dynamic scrolling that padding the header is the way to go, which works on one section in my site but not on another.



    I thought perhaps it was because I'm loading content dynamically and adding content to the dom, but doesn't seem to be the issue since other, static sections have the same issue. It does seem to be when a content section is taller than the viewport. I was originally targeting the id of the container for the section but changed it to the id of the heading with no change.



    If I add offset it can help but inconsistently - works on the about section but the locations section is still way off. I figured it would just scroll the top of the container i'm targeting to the top of the page, but that doesn't seem to be what's happening.



    Example link:



     <li class="nav-item">
    <a class="nav-link nav-btn" href="#" v-scroll-to="'#title-about'" data-toggle="collapse">About</a>
    </li>


    In my app.js:



    Vue.use(VueScrollTo, 
    container: "body",
    offset: -100
    )


    You can see it in action here: lovelaundry



    It seems as though any section that is taller than the viewport doesn't land right - like it positions in the vertical center rather than scrolling to place the top of the targeted element at the top of the viewport, which would be ideal.










    share|improve this question


























      0












      0








      0








      I'm using the wonderful vue-scrollto along with bootstrap. It's working great and lands perfectly when viewed on the desktop. On mobile however, the heading is off the top. I know from previous experience with dynamic scrolling that padding the header is the way to go, which works on one section in my site but not on another.



      I thought perhaps it was because I'm loading content dynamically and adding content to the dom, but doesn't seem to be the issue since other, static sections have the same issue. It does seem to be when a content section is taller than the viewport. I was originally targeting the id of the container for the section but changed it to the id of the heading with no change.



      If I add offset it can help but inconsistently - works on the about section but the locations section is still way off. I figured it would just scroll the top of the container i'm targeting to the top of the page, but that doesn't seem to be what's happening.



      Example link:



       <li class="nav-item">
      <a class="nav-link nav-btn" href="#" v-scroll-to="'#title-about'" data-toggle="collapse">About</a>
      </li>


      In my app.js:



      Vue.use(VueScrollTo, 
      container: "body",
      offset: -100
      )


      You can see it in action here: lovelaundry



      It seems as though any section that is taller than the viewport doesn't land right - like it positions in the vertical center rather than scrolling to place the top of the targeted element at the top of the viewport, which would be ideal.










      share|improve this question
















      I'm using the wonderful vue-scrollto along with bootstrap. It's working great and lands perfectly when viewed on the desktop. On mobile however, the heading is off the top. I know from previous experience with dynamic scrolling that padding the header is the way to go, which works on one section in my site but not on another.



      I thought perhaps it was because I'm loading content dynamically and adding content to the dom, but doesn't seem to be the issue since other, static sections have the same issue. It does seem to be when a content section is taller than the viewport. I was originally targeting the id of the container for the section but changed it to the id of the heading with no change.



      If I add offset it can help but inconsistently - works on the about section but the locations section is still way off. I figured it would just scroll the top of the container i'm targeting to the top of the page, but that doesn't seem to be what's happening.



      Example link:



       <li class="nav-item">
      <a class="nav-link nav-btn" href="#" v-scroll-to="'#title-about'" data-toggle="collapse">About</a>
      </li>


      In my app.js:



      Vue.use(VueScrollTo, 
      container: "body",
      offset: -100
      )


      You can see it in action here: lovelaundry



      It seems as though any section that is taller than the viewport doesn't land right - like it positions in the vertical center rather than scrolling to place the top of the targeted element at the top of the viewport, which would be ideal.







      vue.js vuejs2 bootstrap-4 vue-component scrollto






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 '18 at 19:42







      Dylan Glockler

















      asked Nov 11 '18 at 17:52









      Dylan GlocklerDylan Glockler

      543619




      543619






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I figured out a solution - not very elegant and I doubt it's the best, but it does work and gives me pretty precise control. I created a root method like so:



           scrollTo(target, offset1 = -100, offset2 = -450) 
          //viewport break is 991, offset1 is when greater then 991 for larger viewports, offset2 for smaller
          console.log('1: ' + offset1 + ' ,


          Then I either call this directly from HTML through my laravel blade template:



           <a class="nav-link nav-btn" href="#" v-on:click="scrollTo('#title-about', -100, -250)" data-toggle="collapse">About</a>


          Or emit it up to the parent from a component:



           changeLocation(location) 
          this.$eventHub.$emit('location-loaded', location);
          this.$eventHub.$emit('scroll-to', '#title-locations', -100, -450);
          ,


          In the template:



          <a v-for="loc in locations" v-on:click="changeLocation(loc)" class="dropdown-item nav-btn" v-bind:class=" active: loc.id == location.id "> loc.name </a>


          I still don't quite get how it's working - I have to use different offset values to make it land in the right place if I'm linking from the top of the page or the bottom.






          share|improve this answer






















            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251529%2fvue-scrollto-not-lining-up-on-mobile-offset-for-mobile-only%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









            0














            I figured out a solution - not very elegant and I doubt it's the best, but it does work and gives me pretty precise control. I created a root method like so:



             scrollTo(target, offset1 = -100, offset2 = -450) 
            //viewport break is 991, offset1 is when greater then 991 for larger viewports, offset2 for smaller
            console.log('1: ' + offset1 + ' ,


            Then I either call this directly from HTML through my laravel blade template:



             <a class="nav-link nav-btn" href="#" v-on:click="scrollTo('#title-about', -100, -250)" data-toggle="collapse">About</a>


            Or emit it up to the parent from a component:



             changeLocation(location) 
            this.$eventHub.$emit('location-loaded', location);
            this.$eventHub.$emit('scroll-to', '#title-locations', -100, -450);
            ,


            In the template:



            <a v-for="loc in locations" v-on:click="changeLocation(loc)" class="dropdown-item nav-btn" v-bind:class=" active: loc.id == location.id "> loc.name </a>


            I still don't quite get how it's working - I have to use different offset values to make it land in the right place if I'm linking from the top of the page or the bottom.






            share|improve this answer



























              0














              I figured out a solution - not very elegant and I doubt it's the best, but it does work and gives me pretty precise control. I created a root method like so:



               scrollTo(target, offset1 = -100, offset2 = -450) 
              //viewport break is 991, offset1 is when greater then 991 for larger viewports, offset2 for smaller
              console.log('1: ' + offset1 + ' ,


              Then I either call this directly from HTML through my laravel blade template:



               <a class="nav-link nav-btn" href="#" v-on:click="scrollTo('#title-about', -100, -250)" data-toggle="collapse">About</a>


              Or emit it up to the parent from a component:



               changeLocation(location) 
              this.$eventHub.$emit('location-loaded', location);
              this.$eventHub.$emit('scroll-to', '#title-locations', -100, -450);
              ,


              In the template:



              <a v-for="loc in locations" v-on:click="changeLocation(loc)" class="dropdown-item nav-btn" v-bind:class=" active: loc.id == location.id "> loc.name </a>


              I still don't quite get how it's working - I have to use different offset values to make it land in the right place if I'm linking from the top of the page or the bottom.






              share|improve this answer

























                0












                0








                0







                I figured out a solution - not very elegant and I doubt it's the best, but it does work and gives me pretty precise control. I created a root method like so:



                 scrollTo(target, offset1 = -100, offset2 = -450) 
                //viewport break is 991, offset1 is when greater then 991 for larger viewports, offset2 for smaller
                console.log('1: ' + offset1 + ' ,


                Then I either call this directly from HTML through my laravel blade template:



                 <a class="nav-link nav-btn" href="#" v-on:click="scrollTo('#title-about', -100, -250)" data-toggle="collapse">About</a>


                Or emit it up to the parent from a component:



                 changeLocation(location) 
                this.$eventHub.$emit('location-loaded', location);
                this.$eventHub.$emit('scroll-to', '#title-locations', -100, -450);
                ,


                In the template:



                <a v-for="loc in locations" v-on:click="changeLocation(loc)" class="dropdown-item nav-btn" v-bind:class=" active: loc.id == location.id "> loc.name </a>


                I still don't quite get how it's working - I have to use different offset values to make it land in the right place if I'm linking from the top of the page or the bottom.






                share|improve this answer













                I figured out a solution - not very elegant and I doubt it's the best, but it does work and gives me pretty precise control. I created a root method like so:



                 scrollTo(target, offset1 = -100, offset2 = -450) 
                //viewport break is 991, offset1 is when greater then 991 for larger viewports, offset2 for smaller
                console.log('1: ' + offset1 + ' ,


                Then I either call this directly from HTML through my laravel blade template:



                 <a class="nav-link nav-btn" href="#" v-on:click="scrollTo('#title-about', -100, -250)" data-toggle="collapse">About</a>


                Or emit it up to the parent from a component:



                 changeLocation(location) 
                this.$eventHub.$emit('location-loaded', location);
                this.$eventHub.$emit('scroll-to', '#title-locations', -100, -450);
                ,


                In the template:



                <a v-for="loc in locations" v-on:click="changeLocation(loc)" class="dropdown-item nav-btn" v-bind:class=" active: loc.id == location.id "> loc.name </a>


                I still don't quite get how it's working - I have to use different offset values to make it land in the right place if I'm linking from the top of the page or the bottom.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 '18 at 22:41









                Dylan GlocklerDylan Glockler

                543619




                543619



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251529%2fvue-scrollto-not-lining-up-on-mobile-offset-for-mobile-only%23new-answer', 'question_page');

                    );

                    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







                    Popular posts from this blog

                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                    Crossroads (UK TV series)

                    ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế