How to use scrollTo method in chromy

Best JavaScript code snippet using chromy

scroll_spec.js

Source:scroll_spec.js Github

copy

Full Screen

...31 this.scrollBoth.scrollLeft = 032 })33 describe('subject', () => {34 it('is window by default', () => {35 cy.scrollTo('125px').then(function (win2) {36 expect(this.win).to.eq(win2)37 })38 })39 it('is DOM', () => {40 cy.get('#scroll-to-vertical').scrollTo('125px').then(function ($el) {41 expect($el.get(0)).to.eq(this.scrollVert.get(0))42 })43 })44 it('can use window', () => {45 cy.window().scrollTo('10px').then((win) => {46 expect(win.scrollX).to.eq(10)47 })48 })49 it('can handle window w/length > 1 as a subject', () => {50 cy.visit('/fixtures/dom.html')51 cy.window().should('have.length.gt', 1)52 .scrollTo('10px')53 })54 })55 describe('x axis only', () => {56 it('scrolls x axis to num px', function () {57 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)58 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(0)59 cy.get('#scroll-to-horizontal').scrollTo(300).then(function () {60 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)61 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(300)62 })63 })64 it('scrolls x axis to px', function () {65 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)66 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(0)67 cy.get('#scroll-to-horizontal').scrollTo('125px').then(function () {68 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)69 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(125)70 })71 })72 it('scrolls x axis by % of scrollable height', function () {73 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)74 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(0)75 cy.get('#scroll-to-horizontal').scrollTo('50%').then(function () {76 // they don't calculate the height of the container77 // in the percentage of the scroll (since going the height78 // of the container wouldn't scroll at all...)79 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)80 expect(this.scrollHoriz.get(0).scrollLeft).to.eq((500 - 100) / 2)81 })82 })83 })84 describe('position arguments', () => {85 it('scrolls x/y axis to topLeft', function () {86 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)87 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)88 cy.get('#scroll-to-both').scrollTo('topLeft').then(function () {89 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)90 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)91 })92 })93 it('scrolls x/y axis to top', function () {94 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)95 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)96 cy.get('#scroll-to-both').scrollTo('top').then(function () {97 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)98 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)99 })100 })101 it('scrolls x/y axis to topRight', function () {102 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)103 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)104 cy.get('#scroll-to-both').scrollTo('topRight').then(function () {105 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)106 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100))107 })108 })109 it('scrolls x/y axis to left', function () {110 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)111 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)112 cy.get('#scroll-to-both').scrollTo('left').then(function () {113 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)114 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)115 })116 })117 it('scrolls x/y axis to center', function () {118 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)119 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)120 cy.get('#scroll-to-both').scrollTo('center').then(function () {121 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)122 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)123 })124 })125 it('scrolls x/y axis to right', function () {126 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)127 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)128 cy.get('#scroll-to-both').scrollTo('right').then(function () {129 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)130 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100))131 })132 })133 it('scrolls x/y axis to bottomLeft', function () {134 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)135 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)136 cy.get('#scroll-to-both').scrollTo('bottomLeft').then(function () {137 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100))138 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)139 })140 })141 it('scrolls x/y axis to bottom', function () {142 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)143 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)144 cy.get('#scroll-to-both').scrollTo('bottom').then(function () {145 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100))146 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)147 })148 })149 it('scrolls x/y axis to bottomRight', function () {150 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)151 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)152 cy.get('#scroll-to-both').scrollTo('bottomRight').then(function () {153 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100))154 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100))155 })156 })157 })158 describe('scroll both axis', () => {159 it('scrolls both x and y axis num of px', function () {160 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)161 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)162 cy.get('#scroll-to-both').scrollTo(300, 150).then(function () {163 expect(this.scrollBoth.get(0).scrollTop).to.eq(150)164 expect(this.scrollBoth.get(0).scrollLeft).to.eq(300)165 })166 })167 it('scrolls x to 0 and y num of px', function () {168 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)169 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)170 cy.get('#scroll-to-both').scrollTo(0, 150).then(function () {171 expect(this.scrollBoth.get(0).scrollTop).to.eq(150)172 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)173 })174 })175 it('scrolls x num of px and y to 0 ', function () {176 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)177 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)178 cy.get('#scroll-to-both').scrollTo(150, 0).then(function () {179 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)180 expect(this.scrollBoth.get(0).scrollLeft).to.eq(150)181 })182 })183 it('scrolls both x and y axis of px', function () {184 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)185 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)186 cy.get('#scroll-to-both').scrollTo('300px', '150px').then(function () {187 expect(this.scrollBoth.get(0).scrollTop).to.eq(150)188 expect(this.scrollBoth.get(0).scrollLeft).to.eq(300)189 })190 })191 it('scrolls both x and y axis of percentage', function () {192 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)193 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)194 cy.get('#scroll-to-both').scrollTo('50%', '50%').then(function () {195 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)196 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)197 })198 })199 it('scrolls x to 0 and y percentage', function () {200 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)201 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)202 cy.get('#scroll-to-both').scrollTo('0%', '50%').then(function () {203 expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)204 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)205 })206 })207 it('scrolls x to percentage and y to 0', function () {208 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)209 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)210 cy.get('#scroll-to-both').scrollTo('50%', '0%').then(function () {211 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)212 expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)213 })214 })215 })216 describe('scrolls with options', () => {217 it('calls jQuery scroll to', () => {218 const scrollTo = cy.spy($.fn, 'scrollTo')219 cy.get('#scroll-to-both').scrollTo('25px').then(() => {220 expect(scrollTo).to.be.calledWith({ left: '25px', top: 0 })221 })222 })223 it('sets duration to 0 by default', () => {224 const scrollTo = cy.spy($.fn, 'scrollTo')225 cy.get('#scroll-to-both').scrollTo('25px').then(() => {226 expect(scrollTo).to.be.calledWithMatch({}, { duration: 0 })227 })228 })229 it('sets axis to correct xy', () => {230 const scrollTo = cy.spy($.fn, 'scrollTo')231 cy.get('#scroll-to-both').scrollTo('25px', '80px').then(() => {232 expect(scrollTo).to.be.calledWithMatch({}, { axis: 'xy' })233 })234 })235 it('scrolling resolves after a set duration', function () {236 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)237 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(0)238 const scrollTo = cy.spy($.fn, 'scrollTo')239 cy.get('#scroll-to-horizontal').scrollTo('125px', { duration: 500 }).then(function () {240 expect(scrollTo).to.be.calledWithMatch({}, { duration: 500 })241 expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)242 expect(this.scrollHoriz.get(0).scrollLeft).to.eq(125)243 })244 })245 it('accepts duration string option', () => {246 const scrollTo = cy.spy($.fn, 'scrollTo')247 cy.get('#scroll-to-both').scrollTo('25px', { duration: '500' }).then(() => {248 expect(scrollTo.args[0][1].duration).to.eq('500')249 })250 })251 it('has easing set to swing by default', () => {252 const scrollTo = cy.spy($.fn, 'scrollTo')253 cy.get('#scroll-to-both').scrollTo('25px').then(() => {254 expect(scrollTo.args[0][1].easing).to.eq('swing')255 })256 })257 it('scrolling resolves after easing', function () {258 expect(this.scrollBoth.get(0).scrollTop).to.eq(0)259 expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)260 const scrollTo = cy.spy($.fn, 'scrollTo')261 cy.get('#scroll-to-both').scrollTo('25px', '50px', { easing: 'linear' }).then(function () {262 expect(scrollTo).to.be.calledWithMatch({}, { easing: 'linear' })263 expect(this.scrollBoth.get(0).scrollTop).to.eq(50)264 expect(this.scrollBoth.get(0).scrollLeft).to.eq(25)265 })266 })267 it('retries until element is scrollable', () => {268 const $container = cy.$$('#nonscroll-becomes-scrollable')269 expect($container.get(0).scrollTop).to.eq(0)270 expect($container.get(0).scrollLeft).to.eq(0)271 let retried = false272 cy.on('command:retry', _.after(2, () => {273 $container.css('overflow', 'scroll')274 retried = true275 }))276 cy.get('#nonscroll-becomes-scrollable').scrollTo(500, 300).then(() => {277 expect(retried).to.be.true278 expect($container.get(0).scrollTop).to.eq(300)279 expect($container.get(0).scrollLeft).to.eq(500)280 })281 })282 // https://github.com/cypress-io/cypress/issues/1924283 it('skips scrollability check', () => {284 const scrollTo = cy.spy($.fn, 'scrollTo')285 cy.get('button:first').scrollTo('bottom', { ensureScrollable: false }).then(() => {286 cy.stub(cy, 'ensureScrollability')287 expect(scrollTo).to.be.calledWithMatch({}, { ensureScrollable: false })288 expect(cy.ensureScrollability).not.to.be.called289 })290 })291 })292 describe('assertion verification', () => {293 beforeEach(function () {294 cy.on('log:added', (attrs, log) => {295 if (log.get('name') === 'assert') {296 this.lastLog = log297 }298 })299 return null300 })301 it('eventually passes the assertion', () => {302 cy.on('command:retry', _.after(2, () => {303 cy.$$('#scroll-into-view-horizontal').addClass('scrolled')304 }))305 cy306 .get('#scroll-into-view-horizontal')307 .scrollTo('right')308 .should('have.class', 'scrolled').then(function () {309 const { lastLog } = this310 expect(lastLog.get('name')).to.eq('assert')311 expect(lastLog.get('state')).to.eq('passed')312 expect(lastLog.get('ended')).to.be.true313 })314 })315 it('waits until the subject is scrollable', () => {316 cy.stub(cy, 'ensureScrollability')317 .onFirstCall().throws(new Error())318 cy.on('command:retry', () => {319 return cy.ensureScrollability.returns()320 })321 cy322 .get('#scroll-into-view-horizontal')323 .scrollTo('right').then(() => {324 expect(cy.ensureScrollability).to.be.calledTwice325 })326 })327 })328 describe('errors', {329 defaultCommandTimeout: 50,330 }, () => {331 beforeEach(function () {332 this.logs = []333 cy.on('log:added', (attrs, log) => {334 this.lastLog = log335 this.logs.push(log)336 })337 return null338 })339 it('throws when subject isn\'t scrollable', (done) => {340 cy.on('fail', (err) => {341 expect(err.message).to.include('`cy.scrollTo()` failed because this element is not scrollable:')342 expect(err.message).to.include(`\`<button>button</button>\``)343 expect(err.message).to.include('Make sure you\'re targeting the correct element or use `{ensureScrollable: false}` to disable the scrollable check.')344 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')345 done()346 })347 cy.get('button:first').scrollTo('bottom')348 })349 context('subject errors', () => {350 it('throws when not passed DOM element as subject', (done) => {351 cy.on('fail', (err) => {352 expect(err.message).to.include('`cy.scrollTo()` failed because it requires a DOM element.')353 expect(err.message).to.include('{foo: bar}')354 expect(err.message).to.include('> `cy.noop()`')355 done()356 })357 cy.noop({ foo: 'bar' }).scrollTo('250px')358 })359 it('throws if scrollable container is multiple elements', (done) => {360 cy.on('fail', (err) => {361 expect(err.message).to.include('`cy.scrollTo()` can only be used to scroll 1 element, you tried to scroll 2 elements.')362 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')363 done()364 })365 cy.get('button').scrollTo('500px')366 })367 })368 context('argument errors', () => {369 it('throws if no args passed', (done) => {370 cy.on('fail', (err) => {371 expect(err.message).to.include('`cy.scrollTo()` must be called with a valid `position`. It can be a string, number or object.')372 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')373 done()374 })375 cy.scrollTo()376 })377 it('throws if NaN', (done) => {378 cy.on('fail', (err) => {379 expect(err.message).to.include('`cy.scrollTo()` must be called with a valid `position`. It can be a string, number or object. Your position was: `25, NaN`')380 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')381 done()382 })383 cy.get('#scroll-to-both').scrollTo(25, 0 / 0)384 })385 it('throws if Infinity', (done) => {386 cy.on('fail', (err) => {387 expect(err.message).to.include('`cy.scrollTo()` must be called with a valid `position`. It can be a string, number or object. Your position was: `25, Infinity`')388 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')389 done()390 })391 cy.get('#scroll-to-both').scrollTo(25, 10 / 0)392 })393 it('throws if unrecognized position', (done) => {394 cy.on('fail', (err) => {395 expect(err.message).to.include('Invalid position argument: `botom`. Position may only be topLeft, top, topRight, left, center, right, bottomLeft, bottom, bottomRight.')396 done()397 })398 cy.get('#scroll-to-both').scrollTo('botom')399 })400 })401 context('option errors', () => {402 it('throws if duration is not a number or valid string', (done) => {403 cy.on('fail', (err) => {404 expect(err.message).to.include('`cy.scrollTo()` must be called with a valid `duration`. Duration may be either a number (ms) or a string representing a number (ms). Your duration was: `foo`')405 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')406 done()407 })408 cy.get('#scroll-to-both').scrollTo('25px', { duration: 'foo' })409 })410 it('throws if unrecognized easing', (done) => {411 cy.on('fail', (err) => {412 expect(err.message).to.include('`cy.scrollTo()` must be called with a valid `easing`. Your easing was: `flower`')413 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')414 done()415 })416 cy.get('#scroll-to-both').scrollTo('25px', { easing: 'flower' })417 })418 it('throws if ensureScrollable is not a boolean', (done) => {419 cy.on('fail', (err) => {420 expect(err.message).to.include('`cy.scrollTo()` `ensureScrollable` option must be a boolean. You passed: `force`')421 expect(err.docsUrl).to.eq('https://on.cypress.io/scrollto')422 done()423 })424 cy.get('button:first').scrollTo('bottom', { ensureScrollable: 'force' })425 })426 })427 })428 describe('.log', () => {429 beforeEach(function () {430 this.logs = []431 cy.on('log:added', (attrs, log) => {432 this.lastLog = log433 return this.logs.push(log)434 })435 return null436 })437 it('logs out scrollTo', () => {438 cy.get('#scroll-to-both').scrollTo(25).then(function () {439 const { lastLog } = this440 expect(lastLog.get('name')).to.eq('scrollTo')441 })442 })443 it('passes in $el if child command', () => {444 cy.get('#scroll-to-both').scrollTo(25).then(function ($container) {445 const { lastLog } = this446 expect(lastLog.get('$el').get(0)).to.eq($container.get(0))447 })448 })449 it('passes undefined in $el if parent command', () => {450 cy.scrollTo(25).then(function () {451 const { lastLog } = this452 expect(lastLog.get('$el')).to.be.undefined453 })454 })455 it('logs duration options', () => {456 cy.get('#scroll-to-both').scrollTo(25, { duration: 1 }).then(function () {457 const { lastLog } = this458 expect(lastLog.get('message')).to.eq('25, 0, {duration: 1}')459 })460 })461 it('logs easing options', () => {462 cy.get('#scroll-to-both').scrollTo(25, { easing: 'linear' }).then(function () {463 const { lastLog } = this464 expect(lastLog.get('message')).to.eq('25, 0, {easing: linear}')465 })466 })467 it('snapshots immediately', () => {468 cy.get('#scroll-to-both').scrollTo(25, { duration: 1 }).then(function () {469 const { lastLog } = this470 expect(lastLog.get('snapshots').length).to.eq(1)471 expect(lastLog.get('snapshots')[0]).to.be.an('object')472 })473 })474 it('#consoleProps', () => {475 cy.get('#scroll-to-both').scrollTo(25, { duration: 1 }).then(function ($container) {476 const console = this.lastLog.invoke('consoleProps')477 expect(console.Command).to.eq('scrollTo')478 expect(console.X).to.eq(25)479 expect(console.Y).to.eq(0)480 expect(console.Options).to.eq('{duration: 1}')481 expect(console['Scrolled Element']).to.eq($container.get(0))482 })483 })484 })485 })486 context('#scrollIntoView', () => {487 beforeEach(function () {488 this.win = cy.state('window')489 this.scrollVert = cy.$$('#scroll-into-view-vertical')490 this.scrollHoriz = cy.$$('#scroll-into-view-horizontal')491 this.scrollBoth = cy.$$('#scroll-into-view-both')492 // reset the scrollable containers back493 // to furthest left and top494 this.win.scrollTo(0, 0)495 this.scrollVert.scrollTop(0)496 this.scrollVert.scrollLeft(0)497 this.scrollHoriz.scrollTop(0)498 this.scrollHoriz.scrollLeft(0)499 this.scrollBoth.scrollTop(0)500 this.scrollBoth.scrollLeft(0)501 })502 it('does not change the subject', () => {503 const div = cy.$$('#scroll-into-view-vertical div')504 cy.get('#scroll-into-view-vertical div').scrollIntoView().then(($div) => {505 expect($div).to.match(div)506 })507 })508 it('scrolls x axis of window to element', function () {...

Full Screen

Full Screen

history_init.js

Source:history_init.js Github

copy

Full Screen

...29 30 if (hash == 'intro') {31 $('.menu-item').removeClass('mark');32 $('#sec_intro').addClass('mark');33 $.scrollTo('#modul_intro', 400, {easing:'easeInOutQuart', offset: -20, axis: 'x', onAfter:function(){ 34 // After the scroll35 36 }37 });38 }39 else if (hash == 'pre') {40 $('.menu-item').removeClass('mark');41 $('#sec_pre').addClass('mark');42 $.scrollTo('#modul_pre', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 43 // After the scroll44 45 }46 });47 }48 else if (hash == '-05') {49 $('.menu-item').removeClass('mark');50 $('#sec_-05').addClass('mark');51 $.scrollTo('#modul_-05', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 52 // After the scroll53 54 }55 });56 }57 else if (hash == '-04') {58 $('.menu-item').removeClass('mark');59 $('#sec_-04').addClass('mark');60 $.scrollTo('#modul_-04', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 61 // After the scroll62 63 }64 });65 }66 else if (hash == '-03') {67 $('.menu-item').removeClass('mark');68 $('#sec_-03').addClass('mark');69 $.scrollTo('#modul_-03', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 70 // After the scroll71 72 }73 });74 }75 else if (hash == '-02') {76 $('.menu-item').removeClass('mark');77 $('#sec_-02').addClass('mark');78 $.scrollTo('#modul_-02', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 79 // After the scroll80 81 }82 });83 }84 else if (hash == '-01') {85 $('.menu-item').removeClass('mark');86 $('#sec_-01').addClass('mark');87 $.scrollTo('#modul_-01', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 88 // After the scroll89 90 }91 });92 }93 else if (hash == 'zero') {94 $('.menu-item').removeClass('mark');95 $('#sec_zero').addClass('mark');96 $.scrollTo('#modul_zero', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 97 // After the scroll98 99 }100 });101 }102 else if (hash == '01') {103 $('.menu-item').removeClass('mark');104 $('#sec_01').addClass('mark');105 $.scrollTo('#modul_01', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 106 // After the scroll107 108 }109 });110 }111 else if (hash == '02') {112 $('.menu-item').removeClass('mark');113 $('#sec_02').addClass('mark');114 $.scrollTo('#modul_2', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 115 // After the scroll116 117 }118 });119 }120 121 else if (hash == '03') {122 $('.menu-item').removeClass('mark');123 $('#sec_03').addClass('mark');124 $.scrollTo('#modul_3', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 125 // After the scroll126 127 }128 });129 }130 131 else if (hash == '04') {132 $('.menu-item').removeClass('mark');133 $('#sec_04').addClass('mark');134 $.scrollTo('#modul_4', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 135 // After the scroll136 137 }138 });139 }140 141 else if (hash == '05') {142 $('.menu-item').removeClass('mark');143 $('#sec_05').addClass('mark');144 $.scrollTo('#modul_5', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 145 // After the scroll146 147 }148 });149 }150 151 else if (hash == '06') {152 $('.menu-item').removeClass('mark');153 $('#sec_06').addClass('mark');154 $.scrollTo('#modul_6', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 155 // After the scroll156 157 }158 });159 }160 161 else if (hash == '07') {162 $('.menu-item').removeClass('mark');163 $('#sec_07').addClass('mark');164 $.scrollTo('#modul_7', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 165 // After the scroll166 167 }168 });169 }170 171 else if (hash == '08') {172 $('.menu-item').removeClass('mark');173 $('#sec_08').addClass('mark');174 $.scrollTo('#modul_8', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 175 // After the scroll176 177 }178 });179 }180 else if (hash == '09') {181 $('.menu-item').removeClass('mark');182 $('#sec_09').addClass('mark');183 $.scrollTo('#modul_9', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 184 // After the scroll185 186 }187 });188 }189 else if (hash == '10') {190 $('.menu-item').removeClass('mark');191 $('#sec_10').addClass('mark');192 $.scrollTo('#modul_10', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 193 // After the scroll194 195 }196 });197 }198 else if (hash == '11') {199 $('.menu-item').removeClass('mark');200 $('#sec_11').addClass('mark');201 $.scrollTo('#modul_11', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 202 // After the scroll203 204 }205 });206 }207 208 else if (hash == '12') {209 $('.menu-item').removeClass('mark');210 $('#sec_12').addClass('mark');211 $.scrollTo('#modul_12', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 212 // After the scroll213 214 }215 });216 }217 else if (hash == '13') {218 $('.menu-item').removeClass('mark');219 $('#sec_13').addClass('mark');220 $.scrollTo('#modul_13', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 221 // After the scroll222 223 }224 });225 }226 else if (hash == '14') {227 $('.menu-item').removeClass('mark');228 $('#sec_14').addClass('mark');229 $.scrollTo('#modul_14', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 230 // After the scroll231 232 }233 });234 }235 else if (hash == '15') {236 $('.menu-item').removeClass('mark');237 $('#sec_15').addClass('mark');238 $.scrollTo('#modul_15', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 239 // After the scroll240 241 }242 });243 }244 else if (hash == '16') {245 $('.menu-item').removeClass('mark');246 $('#sec_16').addClass('mark');247 $.scrollTo('#modul_16', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 248 // After the scroll249 250 }251 });252 }253 254 else if (hash == '17') {255 $('.menu-item').removeClass('mark');256 $('#sec_17').addClass('mark');257 $.scrollTo('#modul_17', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 258 // After the scroll259 260 }261 });262 } 263 264 else if (hash == '18') {265 $('.menu-item').removeClass('mark');266 $('#sec_18').addClass('mark');267 $.scrollTo('#modul_18', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 268 // After the scroll269 270 }271 });272 } 273 274 else if (hash == '19') {275 $('.menu-item').removeClass('mark');276 $('#sec_19').addClass('mark');277 $.scrollTo('#modul_19', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 278 // After the scroll279 280 }281 });282 } 283 284 else if (hash == '20') {285 $('.menu-item').removeClass('mark');286 $('#sec_20').addClass('mark');287 $.scrollTo('#modul_20', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 288 // After the scroll289 290 }291 });292 }293 else if (hash == '21') {294 $('.menu-item').removeClass('mark');295 $('#sec_21').addClass('mark');296 $.scrollTo('#modul_21', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 297 // After the scroll298 299 }300 });301 }302 else if (hash == '22') {303 $('.menu-item').removeClass('mark');304 $('#sec_22').addClass('mark');305 $.scrollTo('#modul_22', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 306 // After the scroll307 308 }309 });310 }311 else if (hash == '23') {312 $('.menu-item').removeClass('mark');313 $('#sec_23').addClass('mark');314 $.scrollTo('#modul_23', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 315 // After the scroll316 317 }318 });319 }320 else if (hash == '24') {321 $('.menu-item').removeClass('mark');322 $('#sec_24').addClass('mark');323 $.scrollTo('#modul_24', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 324 // After the scroll325 326 }327 });328 }329 else if (hash == '25') {330 $('.menu-item').removeClass('mark');331 $('#sec_25').addClass('mark');332 $.scrollTo('#modul_25', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 333 // After the scroll334 335 }336 });337 }338 else if (hash == '26') {339 $('.menu-item').removeClass('mark');340 $('#sec_26').addClass('mark');341 $.scrollTo('#modul_26', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 342 // After the scroll343 344 }345 });346 }347 else if (hash == '27') {348 $('.menu-item').removeClass('mark');349 $('#sec_27').addClass('mark');350 $.scrollTo('#modul_27', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 351 // After the scroll352 353 }354 });355 }356 else if (hash == '28') {357 $('.menu-item').removeClass('mark');358 $('#sec_28').addClass('mark');359 $.scrollTo('#modul_28', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 360 // After the scroll361 362 }363 });364 }365 else if (hash == '29') {366 $('.menu-item').removeClass('mark');367 $('#sec_29').addClass('mark');368 $.scrollTo('#modul_29', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 369 // After the scroll370 371 }372 });373 }374 else if (hash == '30') {375 $('.menu-item').removeClass('mark');376 $('#sec_30').addClass('mark');377 $.scrollTo('#modul_30', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 378 // After the scroll379 380 }381 });382 }383 else if (hash == '31') {384 $('.menu-item').removeClass('mark');385 $('#sec_31').addClass('mark');386 $.scrollTo('#modul_31', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 387 // After the scroll388 389 }390 });391 }392 else if (hash == '32') {393 $('.menu-item').removeClass('mark');394 $('#sec_32').addClass('mark');395 $.scrollTo('#modul_32', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 396 // After the scroll397 398 }399 });400 }401 else if (hash == '33') {402 $('.menu-item').removeClass('mark');403 $('#sec_33').addClass('mark');404 $.scrollTo('#modul_33', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 405 // After the scroll406 407 }408 });409 }410 else if (hash == '34') {411 $('.menu-item').removeClass('mark');412 $('#sec_34').addClass('mark');413 $.scrollTo('#modul_34', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 414 // After the scroll415 416 }417 });418 }419 else if (hash == '35') {420 $('.menu-item').removeClass('mark');421 $('#sec_35').addClass('mark');422 $.scrollTo('#modul_35', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 423 // After the scroll424 425 }426 });427 }428 else if (hash == '36') {429 $('.menu-item').removeClass('mark');430 $('#sec_36').addClass('mark');431 $.scrollTo('#modul_36', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 432 // After the scroll433 434 }435 });436 }437 else if (hash == '37') {438 $('.menu-item').removeClass('mark');439 $('#sec_37').addClass('mark');440 $.scrollTo('#modul_37', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 441 // After the scroll442 443 }444 });445 }446 else if (hash == '38') {447 $('.menu-item').removeClass('mark');448 $('#sec_38').addClass('mark');449 $.scrollTo('#modul_38', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 450 // After the scroll451 452 }453 });454 }455 else if (hash == '39') {456 $('.menu-item').removeClass('mark');457 $('#sec_39').addClass('mark');458 $.scrollTo('#modul_39', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 459 // After the scroll460 461 }462 });463 }464 else if (hash == '40') {465 $('.menu-item').removeClass('mark');466 $('#sec_40').addClass('mark');467 $.scrollTo('#modul_40', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 468 // After the scroll469 470 }471 });472 }473 else if (hash == '41') {474 $('.menu-item').removeClass('mark');475 $('#sec_41').addClass('mark');476 $.scrollTo('#modul_41', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 477 // After the scroll478 479 }480 });481 }482 else if (hash == '42') {483 $('.menu-item').removeClass('mark');484 $('#sec_42').addClass('mark');485 $.scrollTo('#modul_42', 400, {easing:'easeInOutQuart', offset: 0, axis: 'x', onAfter:function(){ 486 // After the scroll487 488 }489 });490 }491 else if (hash == 'start') {492 }493 494 else {495 //alert('Denna sidan finns ej');496 }497 498 499 } else {...

Full Screen

Full Screen

scrolljs.js

Source:scrolljs.js Github

copy

Full Screen

...10 $('li').children().css('background-color', '#eeeeee')11 if(this.className.animVal.indexOf('blocklySelected') > 0) {12 for(var i = 0,length = this.childNodes.length; i < length; i++) {13 if(this.childNodes[i].className.baseVal.indexOf('cover') > 0) {14 scrollTo('yaokq');15 } else if(this.childNodes[i].className.baseVal.indexOf('left_turn') > 0) {16 scrollTo('turnleft');17 } else if(this.childNodes[i].className.baseVal.indexOf('right_turn') > 0) {18 scrollTo('turnright');19 } else if(this.childNodes[i].className.baseVal.indexOf('go_forward') > 0) {20 scrollTo('goahead');21 } else if(this.childNodes[i].className.baseVal.indexOf('go_reverse') > 0) {22 scrollTo('goback');23 } else if(this.childNodes[i].className.baseVal.indexOf('stop') > 0) {24 scrollTo('stop');25 } else if(this.childNodes[i].className.baseVal.indexOf('catHandle') > 0) {26 scrollTo('catwave');27 } else if(this.childNodes[i].className.baseVal.indexOf('catSound') > 0) {28 scrollTo('catSound ');29 } else if(this.childNodes[i].className.baseVal.indexOf('firstBtn') > 0) {30 scrollTo('firstBtn '); 31 }else if(this.childNodes[i].className.baseVal.indexOf('secondBtn') > 0) {32 scrollTo('secondBtn ');33 }else if(this.childNodes[i].className.baseVal.indexOf('backBtn') > 0) {34 scrollTo('backBtn ');35 }else if(this.childNodes[i].className.baseVal.indexOf('hammerKnock') > 0) {36 scrollTo('hammerKnock ');37 }else if(this.childNodes[i].className.baseVal.indexOf('numberLives') > 0) {38 scrollTo('numberLives ');39 }else if(this.childNodes[i].className.baseVal.indexOf('scanningGoForward') > 0) {40 scrollTo('scanningGoForward');41 }else if(this.childNodes[i].className.baseVal.indexOf('obstacleGoBack') > 0) {42 scrollTo('obstacleGoBack ');43 }else if(this.childNodes[i].className.baseVal.indexOf('presShake') > 0) {44 scrollTo('presShake');45 }else if(this.childNodes[i].className.baseVal.indexOf('pursuit') > 0) {46 scrollTo('pursuit1');47 }else if(this.childNodes[i].className.baseVal.indexOf('Score') > 0) {48 scrollTo('Score');49 }else if(this.childNodes[i].className.baseVal.indexOf('basketSpeed') > 0) {50 scrollTo('basketSpeed');51 }else if(this.childNodes[i].className.baseVal.indexOf('control_Button_if') > 0) {52 scrollTo('control_Button_if');53 }else if(this.childNodes[i].className.baseVal.indexOf('control_IRsensor_if') > 0) {54 scrollTo('control_IRsensor_if');55 }else if(this.childNodes[i].className.baseVal.indexOf('play_note') > 0) {56 scrollTo('play_note');57 }else if(this.childNodes[i].className.baseVal.indexOf('play_song') > 0) {58 scrollTo('play_song');59 }else if(this.childNodes[i].className.baseVal.indexOf('policeLight') > 0) {60 scrollTo('policeLight');61 }else if(this.childNodes[i].className.baseVal.indexOf('greenLED') > 0) {62 scrollTo('greenLED');63 }else if(this.childNodes[i].className.baseVal.indexOf('redLED') > 0) {64 scrollTo('redLED');65 }else if(this.childNodes[i].className.baseVal.indexOf('blueLED') > 0) {66 scrollTo('blueLED');67 }else if(this.childNodes[i].className.baseVal.indexOf('yellowLED') > 0) {68 scrollTo('yellowLED');69 }else if(this.childNodes[i].className.baseVal.indexOf('offLED') > 0) {70 scrollTo('offLED');71 }else if(this.childNodes[i].className.baseVal.indexOf('leftturn_light_flash') > 0) {72 scrollTo('leftturn_light_flash');73 }else if(this.childNodes[i].className.baseVal.indexOf('leftturn_light_off') > 0) {74 scrollTo('leftturn_light_off');75 }else if(this.childNodes[i].className.baseVal.indexOf('leftturn_light_on') > 0) {76 scrollTo('leftturn_light_on');77 }else if(this.childNodes[i].className.baseVal.indexOf('rightturn_light_flash') > 0) {78 scrollTo('rightturn_light_flash');79 }else if(this.childNodes[i].className.baseVal.indexOf('rightturn_light_off') > 0) {80 scrollTo('rightturn_light_off');81 }else if(this.childNodes[i].className.baseVal.indexOf('rightturn_light_on') > 0) {82 scrollTo('rightturn_light_on');83 }else if(this.childNodes[i].className.baseVal.indexOf('rear_light_on') > 0) {84 scrollTo('rear_light_on');85 }else if(this.childNodes[i].className.baseVal.indexOf('rear_light_off') > 0) {86 scrollTo('rear_light_off');87 }88 89 90 }91 }92 })93 }, 500);94}95function scrollTo(a) {96 iscroll.scrollToElement('.' + a, 500, null, -50, IScroll.utils.ease.bounce);97 timeout = setTimeout(function() {98 $('.' + a).css('background-color', '#ffffff');99 $('.' + a + ' ul li').children().css('background-color', '#fff')100 }, 200);101 return false;102}103//setInterval(function (){104// $('.blocklyText').each(function(){105// if($(this).html() == '如果'||$(this).html() == '执行'||$(this).html() == '否则'||$(this).html() == '否则如果'||$(this).html() == '重复'){106// $(this).css('fill','#514F50')107// }108// });109//},17)

Full Screen

Full Screen

jquery.scrollto.js

Source:jquery.scrollto.js Github

copy

Full Screen

1/**2 * @depends jquery3 * @name jquery.scrollto4 * @package jquery-scrollto {@link http://balupton.com/projects/jquery-scrollto}5 */6/**7 * jQuery Aliaser8 */9(function($){10 /**11 * jQuery ScrollTo (balupton edition)12 * @version 1.0.113 * @date August 31, 201014 * @since 0.1.0, August 27, 201015 * @package jquery-scrollto {@link http://balupton.com/projects/jquery-scrollto}16 * @author Benjamin "balupton" Lupton {@link http://balupton.com}17 * @copyright (c) 2010 Benjamin Arthur Lupton {@link http://balupton.com}18 * @license MIT License {@link http://creativecommons.org/licenses/MIT/}19 */20 if ( !($.ScrollTo||false) ) {21 $.ScrollTo = {22 /**23 * The Default Configuration24 */25 config: {26 duration: 400,27 easing: 'swing',28 callback: undefined,29 durationMode: 'each'30 },31 /**32 * Configure ScrollTo33 */34 configure: function(options){35 var ScrollTo = $.ScrollTo;36 // Apply Options to Config37 $.extend(ScrollTo.config, options||{});38 // Chain39 return this;40 },41 /**42 * Perform the Scroll Animation for the Collections43 * We use $inline here, so we can determine the actual offset start for each overflow:scroll item44 * Each collection is for each overflow:scroll item45 */46 scroll: function(collections, config){47 var ScrollTo = $.ScrollTo;48 // Determine the Scroll49 var collection = collections.pop(),50 $container = collection.$container,51 $target = collection.$target;52 // Prepare the Inline Element of the Container53 var $inline = $('<span/>').css({54 'position': 'absolute',55 'top': '0px',56 'left': '0px'57 });58 var position = $container.css('position');59 // Insert the Inline Element of the Container60 $container.css('position','relative');61 $inline.appendTo($container);62 // Determine the Offsets63 var startOffset = $inline.offset().top,64 targetOffset = $target.offset().top,65 offsetDifference = targetOffset - startOffset;66 // Reset the Inline Element of the Container67 $inline.remove();68 $container.css('position',position);69 // Prepare the callback70 var callback = function(event){71 // Check72 if ( collections.length === 0 ) {73 // Callback74 if ( typeof config.callback === 'function' ) {75 config.callback.apply(this,[event]);76 }77 }78 else {79 // Recurse80 ScrollTo.scroll(collections,config);81 }82 // Return true83 return true;84 };85 // Perform the Scroll86 $container.animate({87 'scrollTop': offsetDifference+'px'88 }, config.duration, config.easing, callback);89 // Return true90 return true;91 },92 /**93 * ScrollTo the Element using the Options94 */95 fn: function(options){96 var ScrollTo = $.ScrollTo;97 // Prepare98 var $target = $(this);99 if ( $target.length === 0 ) {100 // Chain101 return this;102 }103 // Fetch104 var $container = $target.parent(),105 collections = [];106 // Handle Options107 config = $.extend({},ScrollTo.config,options);108 // Cycle through the containers109 while ( $container.length === 1 && !$container.is('body') && !($container.get(0) === document) ) {110 // Check Container111 var container = $container.get(0);112 if ( $container.css('overflow-y') !== 'visible' && container.scrollHeight !== container.clientHeight ) {113 // Push the Collection114 collections.push({115 '$container': $container,116 '$target': $target117 });118 // Update the Target119 $target = $container;120 }121 // Update the Container122 $container = $container.parent();123 }124 // Add the final collection125 collections.push({126 '$container': $($.browser.msie ? 'html' : 'body'),127 '$target': $target128 });129 // Adjust the Config130 if ( config.durationMode === 'all' ) {131 config.duration /= collections.length;132 }133 // Handle134 ScrollTo.scroll(collections,config);135 // Chain136 return this;137 },138 /**139 * Construct140 */141 construct: function(options){142 var ScrollTo = $.ScrollTo;143 // Apply our jQuery Function144 $.fn.ScrollTo = ScrollTo.fn;145 // Apply our Options to the Default Config146 ScrollTo.config = $.extend(ScrollTo.config,options);147 // Chain148 return this;149 }150 };151 // Construct It152 $.ScrollTo.construct();153 }154 else {155 window.console.warn("$.ScrollTo has already been defined...");156 }...

Full Screen

Full Screen

scrollto.js

Source:scrollto.js Github

copy

Full Screen

1+ function ($) {2 'use strict';3 // SCROLLTO CLASS DEFINITION4 // ======================5 var scrto = '[data-toggle="scroll"][href*="#"]:not([href="#"])'6 var Scrollto = function (element, options) {7 this.element = '#' + $(element).attr('id')8 this.$element = $(element)9 this.options = $.extend({}, Scrollto.DEFAULTS, options)10 if (this.options.toggle) this.toggle();11 }12 Scrollto.VERSION = '0.3.0'13 Scrollto.TRANSITION_DURATION = 'slow'14 Scrollto.DEFAULTS = {15 toggle: true,16 target: '0'17 }18 Scrollto.prototype.toggle = function () {19 //if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {20 var target, hash21 if (this.$element !== undefined && this.element.indexOf('#') === 0) {22 target = $(this.element)23 hash = this.element24 } else {25 target = $(this.hash)26 hash = this.hash27 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']')28 }29 30 if (target.length) {31 $('html, body').animate({32 scrollTop: target.offset().top33 }, Scrollto.TRANSITION_DURATION, function () {34 setTimeout(function () {35 window.location.hash = hash36 }, 50)37 })38 return false39 }40 //}41 }42 // SCROLLTO PLUGIN DEFINITION43 // =======================44 function Plugin(option) {45 return this.each(function () {46 var $this = $(this)47 var data = $this.data('bs.scrollto')48 var options = $.extend({}, Scrollto.DEFAULTS, $this.data(), typeof option === 'object' && option)49 if (!data) $this.data('bs.scrollto', (data = new Scrollto(this, options)))50 if (typeof option === 'string') data[option]()51 })52 }53 var old = $.fn.scrollto54 $.fn.scrollto = Plugin55 $.fn.scrollto.Constructor = Scrollto56 // SCROLLTO NO CONFLICT57 // =================58 $.fn.scrollto.noConflict = function () {59 $.fn.scrollto = old60 return this61 }62 // SCROLLTO DATA-API63 // ==============64 $(document).on('click', scrto, Scrollto.prototype.toggle)...

Full Screen

Full Screen

settings_offset_spec.js

Source:settings_offset_spec.js Github

copy

Full Screen

...12 it('Should animate 3 items', function() {13 cy.get('.aos-animate').should('have.length', 3);14 });15 it('Should animate next 3 items on scroll', function() {16 cy.scrollTo(0, 50);17 cy.get('.aos-animate').should('have.length', 6);18 });19 });20 context('0px', () => {21 before(() => {22 cy.initAOS({23 offset: 024 });25 });26 it('Should animate 9 items', function() {27 cy.get('.aos-animate').should('have.length', 9);28 cy.scrollTo(0, 50);29 cy.get('.aos-animate').should('have.length', 9);30 });31 });32 });33 context('inline', () => {34 before(() => {35 cy.visit('/offset.html');36 cy.initAOS();37 cy.viewport(1280, 500);38 });39 it('Should properly tigger all animations', function() {40 cy.get('.aos-animate').should('have.length', 7);41 cy.scrollTo(0, 1 * 150);42 cy.get('.aos-animate').should('have.length', 8);43 cy.scrollTo(0, 2 * 150);44 cy.get('.aos-animate').should('have.length', 10);45 cy.scrollTo(0, 3 * 150);46 cy.get('.aos-animate').should('have.length', 11);47 cy.scrollTo(0, 4 * 150);48 cy.get('.aos-animate').should('have.length', 13);49 cy.scrollTo(0, 5 * 150);50 cy.get('.aos-animate').should('have.length', 14);51 cy.scrollTo(0, 6 * 150);52 cy.get('.aos-animate').should('have.length', 16);53 cy.scrollTo(0, 7 * 150);54 cy.get('.aos-animate').should('have.length', 17);55 cy.scrollTo(0, 8 * 150);56 cy.get('.aos-animate').should('have.length', 19);57 cy.scrollTo(0, 9 * 150);58 cy.get('.aos-animate').should('have.length', 20);59 cy.scrollTo(0, 10 * 150);60 cy.get('.aos-animate').should('have.length', 22);61 cy.scrollTo(0, 11 * 150);62 cy.get('.aos-animate').should('have.length', 23);63 cy.scrollTo(0, 12 * 150);64 cy.get('.aos-animate').should('have.length', 25);65 cy.scrollTo(0, 13 * 150);66 cy.get('.aos-animate').should('have.length', 26);67 cy.scrollTo(0, 14 * 150);68 cy.get('.aos-animate').should('have.length', 27);69 });70 });...

Full Screen

Full Screen

app.spec.js

Source:app.spec.js Github

copy

Full Screen

...3 cy.visit('http://localhost:3000')4 // cy.get('.css-1ynkv7l').should('be.visible').contains('a').click()5 6 // cy.get('.css-1ynkv7l').should('be.visible').contains('cars we love').click()7 cy.scrollTo('bottom')8 cy.scrollTo('top')9 cy.pause() 10 cy.viewport('macbook-15')11 cy.scrollTo('bottom')12 cy.scrollTo('top')13 cy.pause()14 cy.viewport('macbook-13')15 cy.scrollTo('bottom')16 cy.scrollTo('top')17 cy.pause()18 cy.viewport('macbook-11')19 cy.scrollTo('bottom')20 cy.scrollTo('top')21 cy.pause()22 cy.viewport('ipad-2')23 cy.scrollTo('bottom')24 cy.scrollTo('top')25 cy.pause()26 cy.viewport('ipad-mini')27 cy.scrollTo('bottom')28 cy.scrollTo('top')29 cy.pause()30 cy.viewport('iphone-6+')31 cy.scrollTo('bottom')32 cy.scrollTo('top')33 cy.pause()34 cy.viewport('iphone-6')35 cy.scrollTo('bottom')36 cy.scrollTo('top')37 cy.pause()38 cy.viewport('iphone-5')39 cy.scrollTo('bottom')40 cy.scrollTo('top')41 cy.pause()42 cy.viewport('iphone-4')43 cy.scrollTo('bottom')44 cy.scrollTo('top')45 cy.pause()46 cy.viewport('iphone-3')47 cy.scrollTo('bottom')48 cy.scrollTo('top')49 cy.pause()50 cy.viewport('ipad-2', 'portrait')51 cy.scrollTo('bottom')52 cy.scrollTo('top')53 cy.pause()54 cy.viewport('iphone-4', 'landscape')55 cy.scrollTo('bottom')56 cy.scrollTo('top')57 cy.pause()58 })...

Full Screen

Full Screen

scroll.js

Source:scroll.js Github

copy

Full Screen

1jQuery(function ($) {2 //resetowanie scrolla3 $.scrollTo(0);4 $('#link1').click(function () { $.scrollTo($('#monitorykineskopowe'), 500); });5 $('#link2').click(function () { $.scrollTo($('#zasadakineskop'), 500); });6 $('#link3').click(function () { $.scrollTo($('#maskakineskop'), 500); });7 $('#link4').click(function () { $.scrollTo($('#wadyzaletykineskop'), 500); });8 $('#link5').click(function () { $.scrollTo($('#parametrykineskop'), 500); });9 $('#link6').click(function () { $.scrollTo($('#budowaLCD'), 500); });10 $('#link7').click(function () { $.scrollTo($('#zasadaLCD'), 500); });11 $('#link8').click(function () { $.scrollTo($('#matryceLCD'), 500); });12 $('#link9').click(function () { $.scrollTo($('#wadyzaletyLCD'), 500); });13 $('#link10').click(function () { $.scrollTo($('#parametryLCD'), 500); });14 $('#link11').click(function () { $.scrollTo($('#dsub'), 500); });15 $('#link12').click(function () { $.scrollTo($('#dvi'), 500); });16 $('#link13').click(function () { $.scrollTo($('#hdmi'), 500); });17 $('.scrollup').click(function () { $.scrollTo($('body'), 1000); });18}19);20//ukazanie przycisku21$(window).scroll(function () {22 if ($(this).scrollTop() > 300) $('.scrollup').fadeIn();23 else $('.scrollup').fadeOut();24}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy.scrollTo(0, 1000)2chromy.scrollTo(0, 2000)3chromy.scrollTo(0, 3000)4chromy.scrollTo(0, 4000)5chromy.scrollTo(0, 5000)6chromy.scrollTo(0, 6000)7chromy.scrollTo(0, 7000)8chromy.scrollTo(0, 8000)9chromy.scrollTo(0, 9000)10chromy.scrollTo(0, 10000)11chromy.scrollTo(0, 11000)12chromy.scrollTo(0, 12000)13chromy.scrollTo(0, 13000)14chromy.scrollTo(0, 14000)15chromy.scrollTo(0, 15000)16chromy.scrollTo(0, 16000)17chromy.scrollTo(0, 17000)18chromy.scrollTo(0, 18000)19chromy.scrollTo(0, 19000)20chromy.scrollTo(0, 20000)21chromy.scrollTo(0, 21000)22chromy.scrollTo(0, 22000)23chromy.scrollTo(0, 23000)24chromy.scrollTo(0, 24000)25chromy.scrollTo(0, 25000)26chromy.scrollTo(0, 26000)27chromy.scrollTo(0, 27000)28chromy.scrollTo(0, 28000)29chromy.scrollTo(0, 29000)30chromy.scrollTo(0, 30000)31chromy.scrollTo(0, 31000)32chromy.scrollTo(0, 32000)33chromy.scrollTo(0, 33000)34chromy.scrollTo(0, 34000)35chromy.scrollTo(0, 35000)36chromy.scrollTo(0, 36000)37chromy.scrollTo(0, 37000)38chromy.scrollTo(0, 38000)39chromy.scrollTo(0, 39000)40chromy.scrollTo(0, 40000)41chromy.scrollTo(0, 41000)42chromy.scrollTo(0, 42000)43chromy.scrollTo(0, 43000)44chromy.scrollTo(0, 44000)45chromy.scrollTo(0, 45000)46chromy.scrollTo(0, 46000)47chromy.scrollTo(0, 47000)48chromy.scrollTo(0, 48000)49chromy.scrollTo(0, 49000)50chromy.scrollTo(0, 500

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy.scrollTo(0, 1000);2chromy.wait(1000);3chromy.scrollTo(0, 2000);4chromy.wait(1000);5chromy.scrollTo(0, 3000);6chromy.wait(1000);7chromy.scrollTo(0, 4000);8chromy.wait(1000);9chromy.scrollTo(0, 5000);10chromy.wait(1000);11chromy.scrollTo(0, 6000);12chromy.wait(1000);13chromy.scrollTo(0, 7000);14chromy.wait(1000);15chromy.scrollTo(0, 8000);16chromy.wait(1000);17chromy.scrollTo(0, 9000);18chromy.wait(1000);19chromy.scrollTo(0, 10000);20chromy.wait(1000);21chromy.scrollTo(0, 11000);22chromy.wait(1000);23chromy.scrollTo(0, 12000);24chromy.wait(1000);25chromy.scrollTo(0, 13000);26chromy.wait(1000);27chromy.scrollTo(0, 14000);28chromy.wait(1000);29chromy.scrollTo(0, 15000);30chromy.wait(1000);31chromy.scrollTo(0, 16000);32chromy.wait(1000);33chromy.scrollTo(0, 17000);34chromy.wait(1000);35chromy.scrollTo(0, 18000);36chromy.wait(1000);37chromy.scrollTo(0, 19000);38chromy.wait(1000);39chromy.scrollTo(0, 20000);40chromy.wait(1000);41chromy.scrollTo(0, 21000);42chromy.wait(1000);43chromy.scrollTo(0, 22000);44chromy.wait(1000);45chromy.scrollTo(0, 23000);46chromy.wait(1000);47chromy.scrollTo(0, 24000);48chromy.wait(1000);49chromy.scrollTo(0, 25000);50chromy.wait(1000);51chromy.scrollTo(0, 26000);52chromy.wait(1000);53chromy.scrollTo(0, 27000);54chromy.wait(1000);55chromy.scrollTo(0, 28000);56chromy.wait(1000);57chromy.scrollTo(0, 29000);58chromy.wait(1000);59chromy.scrollTo(0

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy.scrollTo(0, 1000).wait(1000);2chromy.scrollTo(0, 2000).wait(1000);3chromy.scrollTo(0, 3000).wait(1000);4chromy.scrollTo(0, 4000).wait(1000);5chromy.scrollTo(0, 5000).wait(1000);6chromy.scrollTo(0, 6000).wait(1000);7chromy.scrollTo(0, 7000).wait(1000);8chromy.scrollTo(0, 8000).wait(1000);9chromy.scrollTo(0, 9000).wait(1000);10chromy.scrollTo(0, 10000).wait(1000);11chromy.scrollTo(0, 11000).wait(1000);12chromy.scrollTo(0, 12000).wait(1000);13chromy.scrollTo(0, 13000).wait(1000);14chromy.scrollTo(0, 14000).wait(1000);15chromy.scrollTo(0, 15000).wait(1000);16chromy.scrollTo(0, 16000).wait(1000);17chromy.scrollTo(0, 17000).wait(1000);18chromy.scrollTo(0, 18000).wait(1000);19chromy.scrollTo(0, 19000).wait(1000);20chromy.scrollTo(0, 20000).wait(1000);21chromy.scrollTo(0, 21000).wait(1000);22chromy.scrollTo(0, 22000).wait(1000);23chromy.scrollTo(0, 23000).wait(1000);24chromy.scrollTo(0, 24000).wait(1000);25chromy.scrollTo(0, 25000).wait(1000);26chromy.scrollTo(0, 26000).wait(1000);27chromy.scrollTo(0, 27000).wait(1000);28chromy.scrollTo(0, 28000).wait(1000);29chromy.scrollTo(0, 29000).wait(1000);30chromy.scrollTo(0, 30000).wait(1000);31chromy.scrollTo(0, 31000).wait(1000);32chromy.scrollTo(0, 32000).wait(1000);33chromy.scrollTo(0, 33000).wait(1000);

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy.scrollTo(0, 10000);2chromy.wait(5000);3chromy.scrollTo(0, 20000);4chromy.wait(5000);5chromy.scrollTo(0, 30000);6chromy.wait(5000);7chromy.scrollTo(0, 40000);8chromy.wait(5000);9chromy.scrollTo(0, 50000);10chromy.wait(5000);11chromy.scrollTo(0, 60000);12chromy.wait(5000);13chromy.scrollTo(0, 70000);14chromy.wait(5000);15chromy.scrollTo(0, 80000);16chromy.wait(5000);17chromy.scrollTo(0, 90000);18chromy.wait(5000);19chromy.scrollTo(0, 100000);20chromy.wait(5000);21chromy.scrollTo(0, 110000);22chromy.wait(5000);23chromy.scrollTo(0, 120000);24chromy.wait(5000);25chromy.scrollTo(0, 130000);26chromy.wait(5000);27chromy.scrollTo(0, 140000);28chromy.wait(5000);29chromy.scrollTo(0, 150000);30chromy.wait(5000);31chromy.scrollTo(0, 160000);32chromy.wait(5000);33chromy.scrollTo(0, 170000);34chromy.wait(5000);35chromy.scrollTo(0, 180000);36chromy.wait(5000);37chromy.scrollTo(0, 190000);38chromy.wait(5000);39chromy.scrollTo(0, 200000);40chromy.wait(5000);41chromy.screenshot({ path: 'screenshot.png' });42chromy.end();43chromy.run(function() {44 console.log('Done');45 process.exit(0);46});

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy.scrollTo(0, 100)2chromy.scrollTo(0, 1000)3chromy.scrollTo(0, 2000)4chromy.scrollTo(0, 3000)5chromy.scrollTo(0, 4000)6chromy.scrollTo(0, 5000)7chromy.scrollTo(0, 6000)8chromy.scrollTo(0, 7000)9chromy.scrollTo(0, 8000)10chromy.scrollTo(0, 9000)11chromy.scrollTo(0, 10000)12chromy.scrollTo(0, 11000)13chromy.scrollTo(0, 12000)14chromy.scrollTo(0, 13000)15chromy.scrollTo(0, 14000)16chromy.scrollTo(0, 15000)17chromy.scrollTo(0, 16000)18chromy.scrollTo(0, 17000)19chromy.scrollTo(0, 18000)20chromy.scrollTo(0, 19000)21chromy.scrollTo(0, 20000)22chromy.scrollTo(0, 21000)23chromy.scrollTo(0, 22000)24chromy.scrollTo(0, 23000)25chromy.scrollTo(0, 24000)26chromy.scrollTo(0, 25000)27chromy.scrollTo(0, 26000)28chromy.scrollTo(0, 27000)29chromy.scrollTo(0, 28000)30chromy.scrollTo(0, 29000)31chromy.scrollTo(0, 30000)32chromy.scrollTo(0, 31000)33chromy.scrollTo(0, 32000)34chromy.scrollTo(0, 33000)35chromy.scrollTo(0, 34000)36chromy.scrollTo(0, 35000)37chromy.scrollTo(0, 36000)38chromy.scrollTo(0, 37000)39chromy.scrollTo(0, 38000)40chromy.scrollTo(0, 39000)41chromy.scrollTo(0, 40000)42chromy.scrollTo(0, 41000)43chromy.scrollTo(0, 42000)44chromy.scrollTo(0, 43000)45chromy.scrollTo(0, 44000)46chromy.scrollTo(0, 45000)47chromy.scrollTo(0, 46000)48chromy.scrollTo(0, 47000)49chromy.scrollTo(0, 48000)50chromy.scrollTo(0, 49000

Full Screen

Using AI Code Generation

copy

Full Screen

1var chromy = require('chromy');2chromy.chain()3 .type('input[name="q"]', 'chrome')4 .click('input[name="btnG"]')5 .wait('#resultStats')6 .evaluate(function() {7 return document.querySelector('#resultStats').textContent;8 })9 .result(function(result) {10 console.log(result);11 })12 .scrollTo(0, 1000)13 .screenshot('google.png')14 .end()15 .then(function() {16 console.log('done');17 })18 .catch(function(e) {19 console.log(e);20 });21var chromy = require('chromy');22chromy.chain()23 .type('input[name="q"]', 'chrome')24 .click('input[name="btnG"]')25 .wait('#resultStats')26 .evaluate(function() {27 return document.querySelector('#resultStats').textContent;28 })29 .result(function(result) {30 console.log(result);31 })32 .scrollTo(0, 1000)33 .screenshot('google.png')34 .end()35 .then(function() {36 console.log('done');37 })38 .catch(function(e) {39 console.log(e);40 });41var chromy = require('chromy');42chromy.chain()43 .type('input[name="q"]', 'chrome')44 .click('input[name="btnG"]')45 .wait('#resultStats')46 .evaluate(function() {47 return document.querySelector('#resultStats').textContent;48 })49 .result(function(result) {50 console.log(result);51 })52 .scrollTo(0, 1000)53 .screenshot('google.png')54 .end()55 .then(function() {56 console.log('done');57 })58 .catch(function(e) {59 console.log(e);60 });61var chromy = require('chromy');62chromy.chain()63 .type('input[name="q"]', 'chrome')

Full Screen

Using AI Code Generation

copy

Full Screen

1var chromy = new Chromy({ port: 9222, visible: true });2chromy.chain()3 .evaluate(() => {4 window.scrollTo(0, document.body.scrollHeight);5 return document.body.scrollHeight;6 })7 .result((r) => {8 console.log(r);9 })10 .end()11 .then(() => chromy.close())12 .catch((err) => {13 console.log('Error:', err);14 chromy.close();15 });16It is working fine when I am using chromy.scrollTo() method. But I am not able to use scrollTo method of chromy. Can anyone help me out to use this method in chromy?17I am trying to use chromy.scrollTo() method in my code. But it is not working. It is giving me error as below:18var chromy = new Chromy({ port: 9222, visible: true });19chromy.chain()20 .scrollTo(0, 1000)21 .result((r) => {22 console.log(r);23 })24 .end()25 .then(() => chromy.close())26 .catch((err) => {27 console.log('Error:', err);28 chromy.close();29 });30I am trying to use chromy.scrollTo() method in my code. But it is not working. It is giving me error as below:31var chromy = new Chromy({ port: 9222, visible: true });32chromy.chain()33 .scrollTo(0, 1000)34 .result((r) => {35 console.log(r);36 })37 .end()

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy.scrollTo(100, 100);2chromy.scrollTo(100, 100, 100, 100);3chromy.scroll(100, 100);4chromy.scroll(100, 100, 100, 100);5chromy.scrollTo(100, 100);6chromy.scrollTo(100, 100, 100, 100);7chromy.scroll(100, 100);8chromy.scroll(100, 100, 100, 100);9chromy.scrollTo(100, 100);10chromy.scrollTo(100, 100, 100, 100);11chromy.scroll(100, 100);12chromy.scroll(100, 100, 100, 100);13chromy.scrollTo(100, 100);14chromy.scrollTo(100, 100, 100, 100);15chromy.scroll(100, 100);16chromy.scroll(100, 100, 100, 100);17chromy.scrollTo(100, 100);18chromy.scrollTo(100, 100, 100, 100);19chromy.scroll(100, 100);20chromy.scroll(100, 100, 100, 100);21chromy.scrollTo(100, 100);22chromy.scrollTo(100, 100, 100, 100);23chromy.scroll(100, 100);24chromy.scroll(100, 100, 100, 100);25chromy.scrollTo(100, 100);26chromy.scrollTo(100, 100, 100, 100);27chromy.scroll(100, 100);28chromy.scroll(100, 100, 100, 100);29chromy.scrollTo(100, 100);30chromy.scrollTo(100, 100, 100,

Full Screen

Using AI Code Generation

copy

Full Screen

1var chromy = new Chromy({ port: port });2chromy.chain()3 .evaluate(function(){4 return document.body.scrollHeight;5 })6 .result(function(height){7 console.log(height);8 chromy.scrollTo(0, height);9 })10 .end()11 .then(function(){12 chromy.close();13 })14 .catch(function(e){15 console.log(e);16 chromy.close();17 });18var chromy = new Chromy({ port: port });19chromy.chain()20 .evaluate(function(){21 return document.body.scrollHeight;22 })23 .result(function(height){24 console.log(height);25 chromy.scrollTo(0, height);26 })27 .end()28 .then(function(){29 chromy.close();30 })31 .catch(function(e){32 console.log(e);33 chromy.close();34 });35var chromy = new Chromy({ port: port });36chromy.chain()37 .evaluate(function(){38 return document.body.scrollHeight;39 })40 .result(function(height){41 console.log(height);42 chromy.scrollTo(0, height);43 })44 .end()45 .then(function(){46 chromy.close();47 })48 .catch(function(e){49 console.log(e);50 chromy.close();51 });52var chromy = new Chromy({ port: port });53chromy.chain()54 .evaluate(function(){55 return document.body.scrollHeight;56 })57 .result(function(height){58 console.log(height);59 chromy.scrollTo(0, height);60 })61 .end()62 .then(function(){63 chromy.close();64 })65 .catch(function(e){66 console.log(e);67 chromy.close();68 });69var chromy = new Chromy({ port: port });70chromy.chain()71 .evaluate(function(){72 return document.body.scrollHeight;73 })74 .result(function(height){75 console.log(height);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run chromy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful