Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.move(event)
})
document.addEventListener('mouseup', this.up)
},
methods: {
up() {
this.$store.commit('mouseUp')
},
down(event, element) {
this.$store.commit(
'parentBounding',
event.target.parentElement.getBoundingClientRect(),
)
this.$store.commit('mouseDown', element)
},
move: throttle(function(event) { // eslint-disable-line
const element = this.$store.state.mouseElement
if (element) {
const cursorX =
typeof event.clientX === 'number'
? event.clientX
: event.touches[0].clientX
const cursorY =
typeof event.clientY === 'number'
? event.clientY
: event.touches[0].clientY
const squareLeft = this.$store.state.parentBounding.left
const squareRight = this.$store.state.parentBounding.right
const squareTop = this.$store.state.parentBounding.top
const squareBottom = this.$store.state.parentBounding.bottom
/* eslint-disable no-nested-ternary */
const xPosition =
import React from 'react';
import PropTypes from 'prop-types';
import Relay from 'react-relay/classic';
import throttle from 'throttleit';
import { seconds } from 'metrick/duration';
import PusherStore from 'app/stores/PusherStore';
import { formatNumber } from 'app/lib/number';
// We need a `requestUpdate` queue above the React component level so
// AgentsCount components will only perform one `forceFetch` in any
// given time window. I wish this was cleaner, kid, I really do.
const requestUpdate = throttle((callback) => callback(), 3::seconds);
class AgentsCount extends React.PureComponent {
static propTypes = {
organization: PropTypes.shape({
agents: PropTypes.shape({
count: PropTypes.number.isRequired
})
}),
relay: PropTypes.object.isRequired
};
state = {
agentCount: this.props.organization.agents ? this.props.organization.agents.count : 0
};
componentDidMount() {
constructor (props) {
super(props)
this.loadOptions = throttle(this.loadOptions, 500)
}
export function enableCompass() {
let id = Compass.watch(throttle(head => {
toAppService({
msg: {
eventName: 'onCompassChange',
data: {
direction: head
}
}
})
}, 200))
router.currentView().on('destroy', () => {
Compass.unwatch(id)
})
}
export function enableAccelerometer () {
if (window.DeviceMotionEvent) {
let handler = throttle(event => {
let { x, y, z } = {
x: event.accelerationIncludingGravity.x,
y: event.accelerationIncludingGravity.y,
z: event.accelerationIncludingGravity.z
}
if (x == null || y == null || z == null) return
toAppService({
msg: {
eventName: 'onAccelerometerChange',
data: { x, y, z }
}
})
}, 200)
window.addEventListener('devicemotion', handler, false)
router.currentView().on('destroy', () => {
window.removeEventListener('devicemotion', handler, false)
constructor (props) {
super(props)
const view0 = props.viewsMap[props.defaultViewName]
if (!view0) {
throw new Error('Invalid defaultViewName')
}
this.state = {
prev: null,
current: view0,
direction: 'init'
}
this.history = [view0]
this.goto = throttle(this.goto.bind(this), TRANSITION_DURATION)
this.back = throttle(this.back.bind(this), TRANSITION_DURATION)
this.onWillNav = this.onWillNav.bind(this)
this.updateHeight = this.updateHeight.bind(this)
}
export function enableAccelerometer() {
if(window.DeviceMotionEvent){
let handler = throttle(event => {
let {x, y, z} = {
x: event.accelerationIncludingGravity.x,
y: event.accelerationIncludingGravity.y,
z: event.accelerationIncludingGravity.z
}
if (x == null || y == null || z == null) return
toAppService({
msg: {
eventName: 'onAccelerometerChange',
data: {x, y, z}
}
})
}, 200)
window.addEventListener("devicemotion", handler, false);
router.currentView().on('destroy', () => {
window.removeEventListener("devicemotion", handler, false);
export function enableAccelerometer() {
if(window.DeviceMotionEvent){
let handler = throttle(event => {
let {x, y, z} = {
x: event.accelerationIncludingGravity.x,
y: event.accelerationIncludingGravity.y,
z: event.accelerationIncludingGravity.z
}
if (x == null || y == null || z == null) return
toAppService({
msg: {
eventName: 'onAccelerometerChange',
type: 'ON_APPLIFECYCLE_EVENT',
data: {x, y, z}
}
})
}, 200)
window.addEventListener("devicemotion", handler, false);
viewManage.currentView().on('destroy', () => {
export function enableCompass () {
let id = Compass.watch(
throttle(head => {
toAppService({
msg: {
eventName: 'onCompassChange',
data: {
direction: head
}
}
})
}, 200)
)
router.currentView().on('destroy', () => {
Compass.unwatch(id)
})
}
export function enableCompass() {
let id = Compass.watch(throttle(head => {
toAppService({
msg: {
eventName: 'onCompassChange',
type: 'ON_APPLIFECYCLE_EVENT',
data: {
direction: head
}
}
})
}, 200))
viewManage.currentView().on('destroy', () => {
Compass.unwatch(id)
})
}