componentDidMount: function() {
   window.addEventListener('resize', debounce(this.onResize, 150));
   window.addEventListener('webkitfullscreenchange', debounce(this.onResize, 150));
   this.setState({
     componentWidth: ReactDOM.findDOMNode(this).getBoundingClientRect().width
   });
 },
Esempio n. 2
0
function watchAll() {
  watch(['./test/custom-api/service-worker.js'],
    debounce(rebuildServiceWorker, 700, {leading: true}));
  watch(['./test/custom-api/service-worker-test.js'],
    debounce(rebuildServiceWorkerTest, 700, {leading: true}));
  watch(['./test/test.js";'],
    debounce(rebuildTestBundle, 700, {leading: true}));
}
Esempio n. 3
0
function watchAll() {
  watch(['packages/node_modules/*/src/**/*.js'],
    debounce(rebuildPouch, 700, {leading: true}));
  watch(['tests/integration/utils.js'],
    debounce(rebuildTestUtils, 700, {leading: true}));
  watch(['tests/performance/**/*.js'],
    debounce(rebuildPerf, 700, {leading: true}));
}
Esempio n. 4
0
  init() {
    const _self = this;

    this.renderPlaceholder();
    $(window).on("resize", _debounce(_self.renderPlaceholder.bind(_self), 100));

    this._resultsHandler = new ResultsHandler(this._context, this._config);
    this._$element.SEARCH_SHOW.on('click', function (e) {
      e.preventDefault();
      _self.showSearchForm();
    });

    this._$element.SEARCH_HIDE.on('click', function (e) {
      e.preventDefault();
      _self.hideSearchForm();
    });


    _self._debouncedGetResults = _debounce(_self.getResults.bind(_self), _self._config.debounceDelay);

    this._$element.SEARCH_INPUT.on('keyup', function (e) {
      const queryString = $(this).val().trim();

      if (ActionKeys.indexOf(e.keyCode) === -1) {
        _self._resultsHandler.updateQuery(queryString)
        _self.loadingAnimationStart();
        if (!queryString) {
          _self.reset();
          return;
        }
        _self._resultsHandler.loadingAnimationStart();
        _self._queryString = queryString;
        _self._debouncedGetResults(queryString);
      }

      if (e.keyCode === KeyCodes.down) {
        if (_self._resultsHandler.shown) {
          _self._resultsHandler.receiveFocus(() => {
            _self._$element.SEARCH_INPUT.focus();
          });
        }
      }

    });



    $(this._context).on(eventNames.BLANKET_CLICK, function () {
      _self.reset();
    });

    $(this._context).on('keyup', function (e) {
      if (e.keyCode === KeyCodes.esc) {
        _self.reset();
      }
    });
  }
Esempio n. 5
0
function Dir(dirpath, sink, wantDir){
  assert(is.string(dirpath))
  assert(sink)
  assert(is.function(sink.emit))
  assert(wantDir == null || is.function(wantDir))

  this.path = dirpath
  this.sink = sink
  this.wantDir = wantDir || function(){ return true }
  this.entries = {}
  this.watcher = null
  this.sink.emit('add', this.path)
  this.update = debounce(this._update.bind(this, false), 200)
  this.forceUpdate = debounce(this._update.bind(this, true), 200)
}
Esempio n. 6
0
var GitGraphViewModel = function(repository) {
	var self = this;
	this.repository = repository;
	this.app = repository.app;
	this.maxNNodes = 25;
	this.nodes = ko.observable([]);
	this.edgesById = {};
	this.refs = ko.observableArray();
	this.daySeparators = ko.observable();
	this.nodesById = {};
	this.refsByRefName = {};
	this.repoPath = repository.repoPath;
	this.isLoading = ko.observable(false);
	this.nodesLoader = new ProgressBarViewModel('gitgraph-' + repository.repoPath, 1000, 400);
	this.checkedOutBranch = ko.observable();
	this.checkedOutRef = ko.computed(function() {
		if (self.checkedOutBranch())
			return self.getRef('refs/heads/' + self.checkedOutBranch());
		else
			return null;
	});
	this.HEAD = ko.observable();
	this.hoverGraphAction = ko.observable();
	this.currentActionContext = ko.observable();
	this.hasRemotes = ko.observable(false);
	this.showDropTargets = ko.computed(function() {
		return !!self.currentActionContext();
	});
	this.scrolledToEnd = debounce(function() {
		self.maxNNodes = self.maxNNodes + 25;
		self.loadNodesFromApi();
	}, 1000, true);
	this.graphic = new GraphViewModel();
	this.graphic.offset(new Vector2(5, 200));
	this.HEAD.subscribe(function(value) {
		self.graphic.commitNodeEdge.nodeb(value);
		self.graphic.showCommitNode(!!value);
		self.graphic.commitNode.color(value.color());
	});

	this.nodes.subscribe(function(nodes) {
		var edges = [];
		nodes.forEach(function(node) {
			node.parents().forEach(function(parentSha1) {
				edges.push(self.getEdge(node.sha1, parentSha1));
			});
		});
		self.graphic.nodes(nodes);
		self.graphic.edges(edges);
	});

	this.hoverGraphAction.subscribe(function(value) {
		if (value) {
			if (value.createHoverGraphic)
				self.graphic.hoverGraphActionGraphic(value.createHoverGraphic());
		} else {
			self.graphic.hoverGraphActionGraphic(null);
		}
	});
}
 constructor(props) {
     super(props);
     const { perPage, sort, filter } = props;
     // stored as a property rather than state because we don't want redraw of async updates
     this.params = { pagination: { page: 1, perPage }, sort, filter };
     this.debouncedSetFilter = debounce(this.setFilter.bind(this), 500);
 }
 $onInit() {
     $(this.$element).find('.ip-container').on('scroll', debounce(
             this.scrollHandler.bind(this),
             100, {trailing: true}
         )
     );
 }
Esempio n. 9
0
 constructor() {
   super();
   this.state = {
     text: '',
   };
   this.search = debounce(this.search, 500);
 }
Esempio n. 10
0
export const formSaver = store => {
	/**
	 * Debounced version of saveAccount() mutation
	 * @since 1.0.0
	 *
	 * @type {Function}
	 */
	this.debounedFormMutation = debounce(
		function(){
			store.dispatch( 'saveAccount' );
		}, 100
	);

	/**
	 * When form setting is mutated trigger update
	 *
	 * @since 1.0.0
	 */
	store.subscribe((mutation, state) => {
		if( 'form' === mutation.type ){
			this.debounedFormMutation();
		}

	})
};
Esempio n. 11
0
  /*
   * @param {Window} container - The Window displaying the list of annotation threads.
   * @param {Thread} rootThread - The initial Thread object for the top-level
   *        threads.
   * @param {Options} options
   */
  constructor($scope, window_, rootThread, options) {
    super();

    const self = this;

    this._rootThread = rootThread;

    this._options = Object.assign({}, options);

    // Cache of thread ID -> last-seen height
    this._heights = {};

    this.window = window_;
    this.scrollRoot = options.scrollRoot || document.body;

    const debouncedUpdate = debounce(function() {
      self.calculateVisibleThreads();
      $scope.$digest();
    }, 20);
    this.scrollRoot.addEventListener('scroll', debouncedUpdate);
    this.window.addEventListener('resize', debouncedUpdate);

    this._detach = function() {
      this.scrollRoot.removeEventListener('scroll', debouncedUpdate);
      this.window.removeEventListener('resize', debouncedUpdate);
    };
  }
Esempio n. 12
0
function buildHeaderScrollScene() {
    const header    = $('header');
    const container = $('.features-container');
    const trigger   = $('.hero .hero-links');

    function calcDuration() {
        return container.outerHeight() + container.offset().top - trigger.offset().top - 70;
    }

    const scene = new ScrollMagic.Scene({
        duration: calcDuration(),
        offset: -22,
        triggerElement: trigger[0],
        triggerHook: 'onLeave'
    }).on('start', (e) => {
        header.toggleClass('is-show-buttons');
    }).on('end', (e) => {
        header.toggleClass('is-hide-buttons');
    }).addTo(scrollController);

    const scene2 = new ScrollMagic.Scene({
        offset: 5,
        triggerElement: 'body',
        triggerHook: 'onLeave'
    }).on('start', () => {
        header.toggleClass('has-shadow');
    }).addTo(scrollController);

    $(window).on('resize', debounce((e) => {
        scene.duration(calcDuration());
    }, 500));
}
Esempio n. 13
0
ViewportStateManager.prototype.attachEvents = function () {
  var debounceTime = this.config.debounceTime;

  this.detectHandler = debounce(this.detectViewportState.bind(this), debounceTime);

  global.addEventListener(this.config.changeEvent, this.detectHandler);
};
  /**
   * setup the scene graph and layout component.
   */
  componentDidMount() {
    // select a base color based on our index in the parent
    const nindex = nodeIndex(this.dom);
    const baseColors = ['rgb(225, 163, 116)', 'rgb(199, 109, 107)', 'rgb(83, 155, 163)'];

    // create the scene graph we are going to use to display the construct
    this.sg = new SceneGraph2D({
      width: this.dom.clientWidth,
      height: this.dom.clientHeight,
      availableWidth: this.dom.clientWidth,
      availableHeight: this.dom.clientHeight,
      parent: this.sceneGraphEl,
      userInterfaceConstructor: UserInterface,
    });
    // create the layout object
    this.layout = new Layout(this, this.sg, {
      layoutAlgorithm: this.props.layoutAlgorithm,
      baseColor: baseColors[nindex % baseColors.length],
    });
    // the user interface will also need access to the layout component
    this.sg.ui.layout = this.layout;
    // getting more ugly, the UI needs access to ourselves, the constructviewer
    this.sg.ui.constructViewer = this;
    // initial render won't call componentDidUpdate so force an update to the layout/scenegraph
    this.update();
    // handle window resize to reflow the layout
    window.addEventListener('resize', debounce(this.windowResized.bind(this), 15));
  }
export default (debounceDelay = 200) => {
  window.addEventListener('resize', debounce(() => {
    LifeTimeEventPublisher.publish(
      new WindowResizedEvent(window.innerHeight, window.innerWidth)
    );
  }, debounceDelay));
};
Esempio n. 16
0
    constructor(element, options) {
        this.el = element;
        this.flashTimeout;
        this.contentEl;
        this.scrollContentEl;
        this.dragOffset         = { x: 0, y: 0 };
        this.isVisible          = { x: true, y: true };
        this.scrollOffsetAttr   = { x: 'scrollLeft', y: 'scrollTop' };
        this.sizeAttr           = { x: 'offsetWidth', y: 'offsetHeight' };
        this.scrollSizeAttr     = { x: 'scrollWidth', y: 'scrollHeight' };
        this.offsetAttr         = { x: 'left', y: 'top' };
        this.globalObserver;
        this.mutationObserver;
        this.resizeObserver;
        this.currentAxis;
        this.isRtl;
        this.options = Object.assign({}, SimpleBar.defaultOptions, options);
        this.classNames = this.options.classNames;
        this.scrollbarWidth = scrollbarWidth();
        this.offsetSize = 20;
        this.flashScrollbar = this.flashScrollbar.bind(this);
        this.onDragY = this.onDragY.bind(this);
        this.onDragX = this.onDragX.bind(this);
        this.onScrollY = this.onScrollY.bind(this);
        this.onScrollX = this.onScrollX.bind(this);
        this.drag = this.drag.bind(this);
        this.onEndDrag = this.onEndDrag.bind(this);
        this.onMouseEnter = this.onMouseEnter.bind(this);

        this.recalculate = debounce(this.recalculate, 100, { leading: true });

        this.init();
    }
  /**
   * setup the scene graph and layout component.
   */
  componentDidMount() {
    // create the scene graph we are going to use to display the construct
    this.sg = new SceneGraph2D({
      width: this.dom.clientWidth,
      height: this.dom.clientHeight,
      availableWidth: this.dom.clientWidth,
      availableHeight: this.dom.clientHeight,
      parent: this.sceneGraphEl,
      userInterfaceConstructor: UserInterface,
    });
    // create the layout object
    this.layout = new Layout(this, this.sg, {});
    // the user interface will also need access to the layout component
    this.sg.ui.layout = this.layout;
    // getting more ugly, the UI needs access to ourselves, the constructviewer
    this.sg.ui.constructViewer = this;
    // initial render won't call componentDidUpdate so force an update to the layout/scenegraph
    this.update();
    // handle window resize to reflow the layout
    this.resizeDebounced = debounce(this.windowResized.bind(this), 5);
    window.addEventListener('resize', this.resizeDebounced);

    // if there is no focused construct then we should grab it
    // NOTE: For now this is disabled because it often does not product the desired result
    // and can move the page beyind the scroll limits set.
    if (!this.props.focus.constructId) {
      this.props.focusConstruct(this.props.constructId);
      //ReactDOM.findDOMNode(this).scrollIntoView();
    } else {
      //ReactDOM.findDOMNode(this).scrollIntoView();
    }
  }
Esempio n. 18
0
  /**
   * Listen for messages coming in from connected frames and add new annotations
   * to the sidebar.
   */
  function setupSyncFromFrame() {
    // A new annotation, note or highlight was created in the frame
    bridge.on('beforeCreateAnnotation', function (event) {
      inFrame.add(event.tag);
      var annot = Object.assign({}, event.msg, {$tag: event.tag});
      $rootScope.$broadcast(events.BEFORE_ANNOTATION_CREATED, annot);
    });

    bridge.on('destroyFrame', destroyFrame.bind(this));

    // Map of annotation tag to anchoring status
    // ('anchored'|'orphan'|'timeout').
    //
    // Updates are coalesced to reduce the overhead from processing
    // triggered by each `UPDATE_ANCHOR_STATUS` action that is dispatched.
    var anchoringStatusUpdates = {};
    var scheduleAnchoringStatusUpdate = debounce(() => {
      store.updateAnchorStatus(anchoringStatusUpdates);
      $rootScope.$broadcast(events.ANNOTATIONS_SYNCED, Object.keys(anchoringStatusUpdates));
      anchoringStatusUpdates = {};
    }, 10);

    // Anchoring an annotation in the frame completed
    bridge.on('sync', function (events_) {
      events_.forEach(function (event) {
        inFrame.add(event.tag);
        anchoringStatusUpdates[event.tag] = event.msg.$orphan ? 'orphan' : 'anchored';
        scheduleAnchoringStatusUpdate();
      });
    });

    bridge.on('showAnnotations', function (tags) {
      store.selectAnnotations(store.findIDsForTags(tags));
      store.selectTab(uiConstants.TAB_ANNOTATIONS);
    });

    bridge.on('focusAnnotations', function (tags) {
      store.focusAnnotations(tags || []);
    });

    bridge.on('toggleAnnotationSelection', function (tags) {
      store.toggleSelectedAnnotations(store.findIDsForTags(tags));
    });

    bridge.on('sidebarOpened', function () {
      $rootScope.$broadcast('sidebarOpened');
    });

    // These invoke the matching methods by name on the Guests
    bridge.on('showSidebar', function () {
      bridge.call('showSidebar');
    });
    bridge.on('hideSidebar', function () {
      bridge.call('hideSidebar');
    });
    bridge.on('setVisibleHighlights', function (state) {
      bridge.call('setVisibleHighlights', state);
    });

  }
Esempio n. 19
0
 constructor(...args) {
   super(...args)
   this._debouncedOnScrollEnd = debounce(this._onScrollEnd, 100)
   this.state = {
     isScrolling: false
   }
 }
Esempio n. 20
0
module.exports = function (targetPath) {
  var autoCommitter = new EventEmitter()
  autoCommitter.iddle = true

  autoCommitter.stop = function () {
    watch.unwatchTree(targetPath)
  }

  autoCommitter.start = function () {
    watch.watchTree(targetPath, { ignoreDotFiles: true }, function () {
      autoCommitter.iddle = false
      autoCommitter.emit('change')
      update()
    })
  }

  var update = debounce(function () {
    commitAll(targetPath).then(function () {
      autoCommitter.iddle = true
      autoCommitter.emit('commit')
    }, function (error) {
      autoCommitter.iddle = true
      autoCommitter.emit('error', error)
    })
  }, 5000)

  return autoCommitter
}
Esempio n. 21
0
  /**
   * Push a modified content onto the stack
   */
  push(content, immediate) {
    if (immediate) { return this.pushFrd(content); }

    if (!this.debouncedPush) {
      this.debouncedPush = debounce(this.pushFrd, 100);
    }
    this.debouncedPush(content);
  }
Esempio n. 22
0
 componentDidUpdate (prevProps: Props, prevState: State) {
   debounce(() => {
     fireResizeEvent()
   }, 300)
   if (this.state.user && !prevState.user) {
     M.FloatingActionButton.init(this.menuButton, {hoverEnabled: false})
   }
 }
Esempio n. 23
0
var Runner = function (options) {
    this.cmd = options.cmd;
    this._running = false;
    this.callbacks = [];
    throttleTime = options.throttleTime || 300;
    this._run = debounce(this._run.bind(this), throttleTime);
    EventEmitter.call(this);
};
Esempio n. 24
0
 constructor(canvas) {
   this._canvas = canvas
   this._ctx = this._canvas.getContext('2d')
   this._initCanvas()
   this._onResize = debounce(this._onResize.bind(this), 100)
   this.render = this.render.bind(this)
   window.addEventListener('resize', this._onResize)
 }
Esempio n. 25
0
  constructor (target) {
    this._target = target;
    this._handledFrames = [];

    this._mutationObserver = new MutationObserver(debounce(() => {
      this._discoverFrames();
    }, DEBOUNCE_WAIT));
  }
  constructor (props) {
    super(props)

    this._debouncedOnActionFilterTextChange = debounce(
      this._onActionFilterTextChange.bind(this),
      DEBOUNCE_TIME
    )
  }
Esempio n. 27
0
  grunt.registerMultiTask('testardo', 'Testing the files with testardo', function() {
    var done = this.async(),
      files = this.filesSrc,
      fail = debounce(function() {
        grunt.fail.fatal({
          message: 'Damn it! Your test failed.. it looks like there is an error somewhere'
        });
      }, 500, false),
      // get the options
      options = buildOptions(this.data.options),
      process;

    // check the files
    files.filter(function(filepath) {
      // Remove nonexistent files (it's up to you to filter or warn here).
      if (!grunt.file.exists(filepath)) {
        grunt.log.warn('Source file "' + filepath + '" not found.');
        return false;
      } else {
        return true;
      }
    });

    // check the files
    if (!files.length) {
      grunt.fail.fatal({
        message: 'Testardo has received no files to test. Check again your paths'
      });
    }

    // trigger the testardo shell command
    process = grunt.util.spawn({
      cmd: __dirname + '/../node_modules/.bin/testardo',
      args: options.concat(files)
    }, function() {
      done(true);
    });

    process.stdout.on('data', function(data) {

      if (!data.length || !/[a-zA-Z]/g.test(data)) {
        return false;
      }
      // testardo was not able to trigger the tests
      if (/testardo/gi.test(data)) {
        grunt.log.write(data);
        done(false);
      } else {
        grunt.log.subhead('Please connect your device to following url to run the tests:');
        grunt.log.oklns(data);
      }
    });
    // listen all the testardo errors
    process.stderr.on('data', function(data) {
      grunt.log.errorlns(data);
      fail();
    });
  });
Esempio n. 28
0
    constructor($scope, $stateParams, $state, $location, $timeout, view, dataStore) {
        this.$scope = $scope;
        this.$state = $state;
        this.$stateParams = $stateParams;
        this.$timeout = $timeout;
        this.view = view;
        this.dataStore = dataStore;
        this.entity = view.getEntity();
        this.actions = view.actions();
        this.batchActions = view.batchActions();
        this.loadingPage = false;
        this.filters = view.filters();
        this.search = ListLayoutController.getCurrentSearchParam($location, this.filters);
        this.path = $location.path();
        // since search isn't a $stateParam of the listLayout state,
        // the controller doesn't change when the search changes
        // so we must update filter values manually when the location changes
        $scope.$watch(
            () => $location.search() && $location.search().search,
            (newval, oldval) => {
                if (newval === oldval) {
                    return;
                }
                if ($location.path() !== this.path) {
                    return; // already transitioned to another page
                }
                this.search = ListLayoutController.getCurrentSearchParam($location, this.filters);
                this.enabledFilters = this.getEnabledFilters();
            }
        );
        // apply filters when filter values change
        $scope.$watch(
            () => this.search,
            debounce((newValues, oldValues) => {
                if (newValues != oldValues) {
                    this.updateFilters();
                }
            }, 500),
            true
        );
        this.filters = view.filters();
        this.enabledFilters = this.getEnabledFilters();
        this.hasFilters = Object.keys(this.filters).length > 0;
        this.focusedFilterId = null;
        this.enableFilter = this.enableFilter.bind(this);
        this.removeFilter = this.removeFilter.bind(this);
        if (this.batchActions.length) {
            // required in scope to communicate with listView
            $scope.selectionUpdater = selection => $scope.selection = selection;
            $scope.selection = [];
        }

        if(this.hasFilters){
            this.updateFilters();
        }

        $scope.$on('$destroy', this.destroy.bind(this));
    }
Esempio n. 29
0
  constructor(props) {
    super(props);

    this.onNextClick = this.onNextClick.bind(this);
    this.onPreviousClick = this.onPreviousClick.bind(this);
    this.debouncedOnNextClick = debounce(this.onNextClick, 100);
    this.debouncedOnPreviousClick = debounce(this.onPreviousClick, 100);

    this.onAddClick = this.onAddClick.bind(this);
    this.onCategoryExpandClick = this.onCategoryExpandClick.bind(this);
    this.onNewCategoryClick = this.onNewCategoryClick.bind(this);
    this.handleOnFeedDrop = this.handleOnFeedDrop.bind(this);

    this.onOPMLImportClick = this.onOPMLImportClick.bind(this);
    this.onSignOutClick = this.onSignOutClick.bind(this);

    this.onSidebarOverlayClick = this.onSidebarOverlayClick.bind(this);
  }
Esempio n. 30
0
 constructor(props) {
   super(props);
   this.state = {
     videos: [],
     selectedVideo: null,
   };
   this.search('pixar');
   this.search = debounce(this.search, 300);
 }