garris / ember-backstop

BackstopJS visual regression testing addon for Ember.
MIT License
56 stars 21 forks source link

Enhancement: Pass options to scrollIntoView() #15

Open danDanV1 opened 5 years ago

danDanV1 commented 5 years ago

@garris do you think this is something that would belong in master or do you expect this type of functionality to exist in the consumer's space?

https://github.com/edeis53/ember-backstop/commit/2ca1b8265c1c0a8ffaf722cf409780e24cace065

scenario.scrollToSelector uses scrollIntoView() under the hood, and sometimes you need use the options supported by scrollIntoView()

eg.

element.scrollIntoView({
      block: "end",
      inline: "end"
    });

Implementation

    const options = {
        scenario: {
             scrollToSelector: "#myid",
             scrollIntoViewOptions: {
                  block: "end",
                  inline: "end"
             }
         }
      }
    await backstop(assert, options);

It's a pity that in the scenario option in backstopjs itself is called scrollToSelector because it's not calling window.scrollTo.

Something like this would have clearer semantics:

 {
        scenario: {
             scrollIntoView: {
                          selector: "#myid",
                          options: {
                               block: "end",
                               inline: "end"
                          }
             }
         }
   }

but that'd be a breaking change in the scenario settings...