question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scrollElements not sync with angular partials

See original GitHub issue

Hi there,

Issue details

I try to use browsersync as a testing tool for my angular application. I’ve got a problem with the option scrollElements who seems to not syncing elements who are in angular templates. For example, I want to sync the scroll on a div with the class .test. Browsersync synchronise the scroll event if this div is in index.html (the layout), but not if this div is in a template call with ui-router.

Steps to reproduce/test case

Launch the gulp task from a terminal and test the scroll sync between Chrome and Firefox.

Please specify which version of Browsersync, node and npm you’re running

  • Browsersync [ 2.13.0 ]
  • Node [ 5.11.0 ]
  • Npm [ 3.8.6 ]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

for all other use-cases, (gulp, grunt etc), please show us exactly how you’re using Browsersync

var gulp = require("gulp");
var browserSync = require('browser-sync');
var browserSyncSpa = require('browser-sync-spa');

gulp.task('serve', function() {

  browserSync.use(browserSyncSpa({
    selector: '[ng-app]',
    history: {
      index: './index.html'
    }
  }));

  browserSync.init({
    server: {
      baseDir: './',
    },
    scrollElements: ['.test'],
    open: false,
    reloadOnRestart: true
  });
});

My app architecture:

App ----node_modules ----partials --------page1.html --------page2.html ----app.js ----gulpfile.js ----index.html ----package.json

Thanks for your help

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
villelahdenvuocommented, Sep 14, 2016

I ended up building my own plugin for BrowserSync. If you’re interested I could post a gist of it.

0reactions
villelahdenvuocommented, Sep 16, 2016

@KBizien Here you go: https://gist.github.com/tuhoojabotti/b35768ba4daec99843e0c5cbab1885c5

To activate it you have to tell BrowserSync to use it in your build script:

browserSync.use({
    plugin() {},
    hooks: {
        // The 'client:js' hook will add your own JS file to the one used by
        // BrowserSync in the browser.
        'client:js': fs.readFileSync(`${__dirname}/browsersync-scroll-plugin.js`)
    }
});

Note: Currently this only restores scroll position when BrowserSync refreshes your page, but you should be able to extend it to sync scroll position to other instances pretty easily.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I synchronize the scroll position of two divs using ...
Unfortunately, I am not having any luck finding the "Angular way" for this problem. Put simply, I need my top div (table header)...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Note: Shared Tab Groups and syncing for Tab Groups, Website Settings, and Web Extensions are not enabled in this release.
Read more >
Angular Translation - Plunker
The reason why we are not using simply a number counter is that * the number ... Is used for deep-linking URLs to...
Read more >
Неожиданные вылеты (failed to execute phase [query])
sizzleFilter?e(b,c,d):e}},pseudos:{not:X(function(a,b,c){var ... a.angular=dd,b}function e(a){return a&&"number"==typeof a.length? ... scrollElement[0].
Read more >
setUpLocationSync - Angular
Works around the problem that onPopState does not trigger history. ... setUpLocationSync(ngUpgrade: UpgradeModule, urlType: "path" | "hash" = 'path') ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found