How to use scrollListener method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

scroll-listener.js

Source:scroll-listener.js Github

copy

Full Screen

1var ScrollListener = {2 firstPage: null,3 4 5 6 finished: false,7 page: 1,8 perPage: 20,9 url: "",10 getParams: null,11 beforeCallback: null,12 afterCallback: null,13 $loaderElement : null,14 method : null,15 $threshold: null,16 id : null,17 loading : false,18 active : false,19 20 off : function() {21 ScrollListener.active = false;22 if (ScrollListener.id != null) {23 $("#" + ScrollListener.id).off("scroll");24 }25 else26 $(document).off("scroll");27 },28 29 init: function(url, method, getParams, beforeCallback, afterCallback, $threshold, firstPage, id,onlyFormData) {30 ScrollListener.off();31 32 ScrollListener.page = 1;33 ScrollListener.url = url;34 ScrollListener.method = method;35 ScrollListener.getParams = getParams;36 ScrollListener.beforeCallback = beforeCallback;37 ScrollListener.afterCallback = afterCallback;38 ScrollListener.finished = false;39 ScrollListener.$threshold = $threshold;40 ScrollListener.firstPage = firstPage;41 ScrollListener.id = id;42 ScrollListener.onlyFormData = onlyFormData;43 ScrollListener.load();44 45 if (ScrollListener.id == null) {46 $(document).on("scroll", function() {47 if (ScrollListener.active) {48 if (ScrollListener.$threshold) {49 if ((!ScrollListener.finished) && ($(window).height() + $(document).scrollTop() >= ScrollListener.$threshold.offset().top)) {50 //$threshold - одноразовый параметр и его следует переназначать во время обновления контента51 ScrollListener.$threshold = null;52 ScrollListener.load();53 } 54 } else {55 if ((!ScrollListener.finished) && ($(window).height() + $(document).scrollTop() == $(document).height())) {56 ScrollListener.load();57 } 58 }59 }60 });61 }62 else63 {64 var div = $("#" + id);65 div.on("scroll", function() {66 if (ScrollListener.active) {67 if (ScrollListener.$threshold) {68 if ((!ScrollListener.finished) && (div.height() + div.scrollTop() >= ScrollListener.$threshold.offset().top)) {69 //$threshold - одноразовый параметр и его следует переназначать во время обновления контента70 ScrollListener.$threshold = null;71 ScrollListener.load();72 } 73 } else {74 if ((!ScrollListener.finished) && (div.height() + div.scrollTop() == div.get(0).scrollHeight)) {75 ScrollListener.load();76 } 77 }78 }79 });80 }81 ScrollListener.active = true;82 83 },84 load: function() {85 86 if (ScrollListener.loading) {87 return;88 }89 90 ScrollListener.loading = true;91 92 var data = ScrollListener.getParams ? ScrollListener.getParams() : {};93 data.page = ScrollListener.page;94 ScrollListener.page += 1;95 if (!data.per_page) {96 data.per_page = ScrollListener.perPage;97 }98 var queryString = "";99 var requestData = {};100 var requestUrl = ScrollListener.url;101 if (ScrollListener.onlyFormData) {102 for (field in data) {103 requestData[field] = data[field];104 }105 }106 else {107 for (field in data) {108 if (field != "query") {109 if (queryString != "") {110 queryString += "&";111 }112 queryString += field + "=" + data[field];113 }114 }115 requestUrl = ScrollListener.url + "?" + queryString;116 requestData.query = data.query;117 }118 if (ScrollListener.beforeCallback) {119 ScrollListener.beforeCallback();120 }121 122 if (ScrollListener.firstPage) {123 if (ScrollListener.afterCallback) {124 ScrollListener.afterCallback(ScrollListener.firstPage, data.page);125 }126 ScrollListener.firstPage = null;127 ScrollListener.loading = false;128 } else {129 $.ajax({130 type: ScrollListener.method,131 dataType: "json",132 data: requestData,133 url: requestUrl,134 success: function(response) {135 if (($.isArray(response) && response.length == 0) || ($.isArray(response.list) && (response.list.length == 0))) {136 ScrollListener.finished = true;137 }138 if (ScrollListener.afterCallback) {139 ScrollListener.afterCallback(response, data.page);140 }141 ScrollListener.loading = false;142 },143 error: function() {144 ScrollListener.loading = false;145 console.log("error");146 }147 });148 }149 150 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import React, { PureComponent } from 'react'2import TouchResponder from './touchResponder'3import ScrollListener from './scrollListener'4import Scrollable from './scrollable'5import RefreshControl from './refreshControl'6import LoadMore from './loadMore'7export class Scroller extends PureComponent {8 recomputeLayout () {9 this.scrollListener.recomputeLayout()10 }11 constructor (props) {12 super(props)13 this.recomputeLayout = this.recomputeLayout.bind(this)14 }15 render () {16 const { children, ...otherProps } = this.props17 return (18 <ScrollListener {...otherProps} ref={s => (this.scrollListener = s)}>19 <TouchResponder>20 <Scrollable>{children}</Scrollable>21 </TouchResponder>22 </ScrollListener>23 )24 }25}26export class ScrollerWithRefresh extends PureComponent {27 recomputeLayout () {28 this.scrollListener.recomputeLayout()29 }30 constructor (props) {31 super(props)32 this.recomputeLayout = this.recomputeLayout.bind(this)33 }34 render () {35 const { children, ...otherProps } = this.props36 return (37 <ScrollListener {...otherProps} ref={s => (this.scrollListener = s)}>38 <TouchResponder>39 <RefreshControl>40 <Scrollable>{children}</Scrollable>41 </RefreshControl>42 </TouchResponder>43 </ScrollListener>44 )45 }46}47export class ScrollerWithLoadMore extends PureComponent {48 recomputeLayout () {49 this.scrollListener.recomputeLayout()50 }51 constructor (props) {52 super(props)53 this.recomputeLayout = this.recomputeLayout.bind(this)54 }55 render () {56 const { children, ...otherProps } = this.props57 return (58 <ScrollListener {...otherProps} ref={s => (this.scrollListener = s)}>59 <TouchResponder>60 <LoadMore>61 <Scrollable>{children}</Scrollable>62 </LoadMore>63 </TouchResponder>64 </ScrollListener>65 )66 }67}68export class ScrollerWithRefreshAndLoadMore extends PureComponent {69 recomputeLayout () {70 this.scrollListener.recomputeLayout()71 }72 constructor (props) {73 super(props)74 this.recomputeLayout = this.recomputeLayout.bind(this)75 }76 render () {77 const { children, ...otherProps } = this.props78 return (79 <ScrollListener {...otherProps} ref={s => (this.scrollListener = s)}>80 <TouchResponder>81 <LoadMore>82 <RefreshControl>83 <Scrollable>{children}</Scrollable>84 </RefreshControl>85 </LoadMore>86 </TouchResponder>87 </ScrollListener>88 )89 }90}...

Full Screen

Full Screen

ScrollListener.js

Source:ScrollListener.js Github

copy

Full Screen

1define("tui/utils/ScrollListener", ["dojo", "dojo/on"], function (dojo, on) {2 dojo.declare("tui.utils.ScrollListener", null, {3 area: 50,4 mode: "vertical",5 domNode: null,6 scrollConnect: null,7 attachOnLoad: true,8 constructor: function (args) {9 var scrollListener = this;10 dojo.safeMixin(scrollListener, args);11 if(scrollListener.attachOnLoad) {12 scrollListener.attach();13 }14 },15 attach: function () {16 var scrollListener = this;17 scrollListener.scrollConnect = on(scrollListener.domNode || window, "scroll", function () {18 scrollListener.scroll()19 });20 return scrollListener;21 },22 detach: function () {23 var scrollListener = this;24 if(scrollListener.scrollConnect) {25 scrollListener.scrollConnect.remove();26 scrollListener.scrollConnect = null;27 return scrollListener;28 }29 return null;30 },31 scroll: function () {32 var scrollListener = this,33 viewport = (scrollListener.domNode) ? dojo.marginBox(scrollListener.domNode) : dojo.window.getBox(),34 scrollHeight,35 scrollWidth;36 var scrollPos = 0;37 if (scrollListener.mode === "vertical") {38 scrollPos = viewport.t + viewport.h;39 scrollHeight = (scrollListener.domNode) ? scrollListener.domNode : dojo.body().scrollHeight;40 if (scrollPos < scrollHeight - scrollListener.area) {41 return;42 }43 } else {44 scrollPos = viewport.l + viewport.w;45 scrollWidth = (scrollListener.domNode) ? scrollListener.domNode : dojo.body().scrollWidth;46 if (scrollPos < scrollWidth - scrollListener.area) {47 return;48 }49 }50 scrollListener.onScroll(scrollPos, scrollListener);51 },52 onScroll: function (scrollPos, scrollListener) {}53 });54 return tui.utils.ScrollListener;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2device.scrollListener(function (scroll) {3 console.log(scroll);4});5var stf = require('devicefarmer-stf');6device.scrollListener(function (scroll) {7 console.log(scroll);8});9var stf = require('devicefarmer-stf');10device.scrollListener(function (scroll) {11 console.log(scroll);12});13var stf = require('devicefarmer-stf');14device.scrollListener(function (scroll) {15 console.log(scroll);16});17var stf = require('devicefarmer-stf');18device.scrollListener(function (scroll) {19 console.log(scroll);20});21var stf = require('devicefarmer-stf');22device.scrollListener(function (scroll) {23 console.log(scroll);24});25var stf = require('devicefarmer-stf');26device.scrollListener(function (scroll) {27 console.log(scroll);28});29var stf = require('devicefarmer-stf');30device.scrollListener(function (scroll) {31 console.log(scroll);32});33var stf = require('devicefarmer-stf');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2stf.getDevices(function (err, devices) {3 if (err) {4 console.log(err);5 } else {6 var device = devices.getDevice('0123456789ABCDEF');7 var scrollListener = device.scrollListener();8 scrollListener.on('scroll', function (event) {9 console.log(event);10 });11 scrollListener.start();12 }13});14scrollListener.stop();

Full Screen

Using AI Code Generation

copy

Full Screen

1var scrollListener = require("devicefarmer-stf").scrollListener;2scrollListener.startScrollListener();3scrollListener.on("scroll", function(event) {4 console.log(event);5});6var swipeListener = require("devicefarmer-stf").swipeListener;7swipeListener.startSwipeListener();8swipeListener.on("swipe", function(event) {9 console.log(event);10});11var touchListener = require("devicefarmer-stf").touchListener;12touchListener.startTouchListener();13touchListener.on("touch", function(event) {14 console.log(event);15});16var gestureListener = require("devicefarmer-stf").gestureListener;17gestureListener.startGestureListener();18gestureListener.on("gesture", function(event) {19 console.log(event);20});21var keyListener = require("devicefarmer-stf").keyListener;22keyListener.startKeyListener();23keyListener.on("key", function(event) {24 console.log(event);25});26var keyListener = require("devicefarmer-stf").keyListener;27keyListener.startKeyListener();28keyListener.on("key", function(event) {29 console.log(event);30});31var keyListener = require("devicefarmer-stf").keyListener;32keyListener.startKeyListener();33keyListener.on("key", function(event) {34 console.log(event);35});36var keyListener = require("devicefarmer-stf").keyListener;37keyListener.startKeyListener();38keyListener.on("key", function(event) {39 console.log(event);40});41var keyListener = require("devicefarmer-stf").keyListener;42keyListener.startKeyListener();43keyListener.on("key", function(event) {44 console.log(event);45});46var keyListener = require("devicefarmer-stf").keyListener;47keyListener.startKeyListener();48keyListener.on("key", function(event) {49 console.log(event);50});

Full Screen

Using AI Code Generation

copy

Full Screen

1var scrollListener = require('devicefarmer-stf').scrollListener;2scrollListener.scroll(100, 100, 100, 100, 1000);3var scrollListener = require('stf-remote-control').scrollListener;4scrollListener.scroll(100, 100, 100, 100, 1000);5var scrollListener = require('stf-remote-control').scrollListener;6scrollListener.scroll(100, 100, 100, 100, 1000);7var scrollListener = require('stf-remote-control').scrollListener;8scrollListener.scroll(100, 100, 100, 100, 1000);9var scrollListener = require('stf-remote-control').scrollListener;10scrollListener.scroll(100, 100, 100, 100, 1000);11var scrollListener = require('stf-remote-control').scrollListener;12scrollListener.scroll(100, 100, 100, 100, 1000);13var scrollListener = require('stf-remote-control').scrollListener;14scrollListener.scroll(100, 100, 100, 100, 1000);15var scrollListener = require('stf-remote-control').scrollListener;16scrollListener.scroll(100, 100, 100, 100, 1000);17var scrollListener = require('stf-remote-control').scrollListener;18scrollListener.scroll(100, 100, 100, 100, 1000);19var scrollListener = require('stf-remote-control').scrollListener;20scrollListener.scroll(100, 100, 100, 100, 1000);21var scrollListener = require('stf-remote-control').scrollListener;

Full Screen

Using AI Code Generation

copy

Full Screen

1const stf = require('devicefarmer-stf-client');2client.getDevices().then((devices) => {3 let device = devices[0];4 device.scrollListener().then((scrollEvents) => {5 scrollEvents.on('scroll', (scrollEvent) => {6 console.log(scrollEvent);7 });8 });9});10Copyright (c) 2016 DeviceFarmer

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var scroll = device.scrollListener('android.widget.TextView', 'text', 'Settings', 5000);3scroll.then(function (result) {4 console.log('Scrolling Done');5});6var stf = require('devicefarmer-stf');7var scroll = device.scroll('android.widget.TextView', 'text', 'Settings');8scroll.then(function (result) {9 console.log('Scrolling Done');10});11var stf = require('devicefarmer-stf');12var scroll = device.scrollDown('android.widget.TextView', 'text', 'Settings');13scroll.then(function (result) {14 console.log('Scrolling Done');15});16var stf = require('devicefarmer-stf');17var scroll = device.scrollUp('android.widget.TextView', 'text', 'Settings');18scroll.then(function (result) {19 console.log('Scrolling Done');20});21var stf = require('devicefarmer-stf');22var scroll = device.scrollLeft('android.widget.TextView', 'text', 'Settings');23scroll.then(function (result) {24 console.log('Scrolling Done');25});26var stf = require('devicefarmer-stf');27var device = stf.connect('

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var wd = require('wd');3var desired = require('./desired');4var serverConfig = require('./serverConfig');5describe('Scrolling', function () {6 this.timeout(300000);7 var driver;8 before(function () {9 driver = wd.promiseChainRemote(serverConfig);10 require('./logging').configure(driver);11 var desired = {12 };13 return driver.init(desired);14 });15 after(function () {16 return driver.quit();17 });18 it('should scroll to the last visible element in the list and then click on it and then scro

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 devicefarmer-stf 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