How to use the base.bind function in base

To help you get started, we’ve selected a few base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gameclosure / devkit-core / timestep / src / platforms / browser / Input.js View on Github external
document.addEventListener('mouseup', (evt) => this.handleMouse(eventTypes.SELECT, evt), { passive: false });
    document.addEventListener('touchend', (evt) => this.handleMouse(eventTypes.SELECT, evt), { passive: false });
    window.addEventListener('DOMMouseScroll', (evt) => this.handleMouse(eventTypes.SCROLL, evt), { passive: false });

    // FF
    // this._handleWheel = $.onEvent(window, 'mousewheel', this, 'handleMouse', eventTypes.SCROLL);
    window.addEventListener('mousewheel', (evt) => this.handleMouse(eventTypes.SCROLL, evt));

    // webkit
    this._addElEvents();

    // this._evtFps = new FPSCounter({name: "mouse events"});
    this._hasFocus = false;
    if (document.addEventListener) {
      document.addEventListener('focus', bind(this, 'onFocusCapture'), true);
      document.addEventListener('blur', bind(this, 'onBlurCapture'), true);
    }
  }
github gameclosure / devkit-core / timestep / src / ui / Engine.js View on Github external
this._opts = opts = merge(opts, {
      keyListenerEnabled: true,
      width: canvas && canvas.width || device.width,
      height: canvas && canvas.height || device.height,
      view: null,
      dtFixed: 0,
      dtMinimum: 0,
      clearEachFrame: true,
      alwaysRepaint: true,
      repaintOnEvent: true,
      mergeMoveEvents: false,
      continuousInputCheck: !device.isMobileBrowser && !device.isMobile,
      showFPS: false
    });

    _timers.push(bind(this, this._tick));

    this._doubleBuffered = true;
    this._countdown = null;

    this._rootElement = new Canvas({
      el: canvas,
      // use an existing canvas if one was provided, but wrap the 2D context
      useWebGL: true,
      // use WebGL if supported
      width: opts.width,
      height: opts.height,
      offscreen: false
    });

    this.useWebGL = this._rootElement.isWebGL;
github gameclosure / devkit-core / timestep / src / ui / layout / BoxLayout.js View on Github external
addResizeListener (view) {
    if (view.style.__removeSuperviewResize) {
      view.style.__removeSuperviewResize();
    }

    // reflow on parent view resize
    var onResize = bind(view, 'needsReflow');
    var superview = view.getSuperview();
    if (superview) {
      superview.on('resize', onResize);
      // store a closure to unsubscribe this event
      view.style.__removeSuperviewResize = bind(view.style, function () {
        this.__removeSuperviewResize = null;
        superview && superview.removeListener('resize', onResize);
      });
    }
  }
  listenSubviewResize (view) {
github gameclosure / devkit-core / timestep / src / ui / ScrollView.js View on Github external
if (offset.x < bounds.minX) {
      tx = bounds.minX;
    } else if (offset.x > bounds.maxX) {
      tx = bounds.maxX;
    }

    dy = ty - offset.y;
    dx = tx - offset.x;

    if (dy === 0 && dx === 0) {
      return;
    }

    this._isBouncing = true;
    this._anim.now(bind(this, function (tt, t) {
      this.setOffset(offset.x + dx * tt, offset.y + dy * tt);
    }), 500, animate.easeInOut).then(bind(this, function () {
      this._canBounce = false;
      this._isBouncing = false;

      // Ensure that after the bounce an update to the bounds has not
      // been ignored.
      this.scrollTo(undefined, undefined, 0);
    }));
  }
  setScrollBounds (bounds) {
github gameclosure / devkit-core / timestep / src / platforms / browser / doc.js View on Github external
case SCALING.FIXED:
        opts = merge(opts, {
          width: device.width,
          height: device.height
        });
        break;
      case SCALING.RESIZE:
        opts = merge(opts, { resizeCanvas: true });
      // fall through:
      case SCALING.MANUAL:
        break;
    }

    this._scalingOpts = opts;
    this.onResize();
    setTimeout(bind(this, 'onResize'), 1000);
  }
github gameclosure / devkit-core / timestep / src / ui / ScrollView.js View on Github external
tx = bounds.minX;
    } else if (offset.x > bounds.maxX) {
      tx = bounds.maxX;
    }

    dy = ty - offset.y;
    dx = tx - offset.x;

    if (dy === 0 && dx === 0) {
      return;
    }

    this._isBouncing = true;
    this._anim.now(bind(this, function (tt, t) {
      this.setOffset(offset.x + dx * tt, offset.y + dy * tt);
    }), 500, animate.easeInOut).then(bind(this, function () {
      this._canBounce = false;
      this._isBouncing = false;

      // Ensure that after the bounce an update to the bounds has not
      // been ignored.
      this.scrollTo(undefined, undefined, 0);
    }));
  }
  setScrollBounds (bounds) {
github gameclosure / devkit-core / timestep / src / ui / layout / BoxLayout.js View on Github external
listenSubviewResize (view) {
    if (view.__root) {
      this.addResizeListener(view);
    }

    view.on('ViewAdded', bind(this, 'addResizeListener', view));
    view.on('ViewRemoved', bind(view.style, function () {
      this.__removeSuperviewResize && this.__removeSuperviewResize();
    }));
  }
  reflowX (superview) {
github gameclosure / devkit-core / timestep / src / ui / layout / BoxLayout.js View on Github external
listenSubviewResize (view) {
    if (view.__root) {
      this.addResizeListener(view);
    }

    view.on('ViewAdded', bind(this, 'addResizeListener', view));
    view.on('ViewRemoved', bind(view.style, function () {
      this.__removeSuperviewResize && this.__removeSuperviewResize();
    }));
  }
  reflowX (superview) {