Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(event: React.PointerEvent) => {
setIsPointerDown(false);
if (trackRef.current) {
trackRef.current.releasePointerCapture(event.pointerId);
}
if (onChangeEnd) {
onChangeEnd(value);
}
},
[onChangeEnd, value],
);
// throttle the pointer move function
const log = throttle(100, (event?: any) => {
// setIsHovering(true)
const nextValue = getValueFromPointer(event);
console.log(nextValue);
});
const onPointerLeave = () => {
// setIsHovering(false)
};
const onPointerMove = (event: React.PointerEvent) => {
event.persist();
log(event);
if (isPointerDown) {
const nextValue = getValueFromPointer(event);
if (nextValue !== value) {
updateValue(nextValue);
constructor() {
super();
// Bind to make 'this' work in callbacks.
this.handleWindowResize = this.handleWindowResize.bind(this);
// Throttle the calls to handleWindowResize() so that we're not constantly re-rendering.
this.throttledHandleWindowResize = throttle(200, true, this.handleWindowResize);
}
animate(updateCanvas) {
let last = Date.now();
let boundCallback;
let fpsUpdate = () => {
this.fps = Math.round(avg(this.frames));
}
let updateFps = throttle(120, fpsUpdate);
function loop() {
let rotations = this.appState.rotations;
this.frame = requestAnimationFrame(boundCallback);
for (let i = 0; i < rotations.length; i++) {
// this.rotations[i].x += 0.01;
// this.rotations[i].y += 0.01;
// this.rotations[i].z += 0.01;
let rotation = rotations[i];
rotation.r = {
x: rotation.r.x + 0.01,
y: rotation.r.y + 0.01,
z: rotation.r.z + 0.01,
}
hasScrolled();
} );
} );
// Set FS video size.
const throttledSetFullscreenVideoSize = throttle( 200, () => {
rafl( () => {
self.setFullscreenVideoSize();
} );
} );
$( window ).on( 'DOMContentLoaded load resize orientationchange', () => {
throttledSetFullscreenVideoSize();
} );
// Init blocks.
const throttledInitBlocks = throttle( 200, () => {
rafl( () => {
self.initBlocks();
} );
} );
if ( window.MutationObserver ) {
new window.MutationObserver( throttledInitBlocks )
.observe( document.documentElement, {
childList: true, subtree: true,
} );
} else {
$( document ).on( 'DOMContentLoaded DOMNodeInserted load', () => {
throttledInitBlocks();
} );
}
// Prepare hash changes.
willInit() {
this.__base(...arguments);
this._calcIsAnchorVisible = this._calcIsAnchorVisible.bind(this);
this.onAnchorParentsScroll = throttle(100, this.onAnchorParentsScroll.bind(this));
this.onViewportResize = throttle(100, this.onViewportResize.bind(this));
this._bindToScroll = this._bindToScroll.bind(this);
this._unbindFromScroll = this._unbindFromScroll.bind(this);
},
})
export class ReminderService {
onReminderActive$ = new Subject();
private _reminders$ = new ReplaySubject(1);
reminders$ = this._reminders$.asObservable();
private _onReloadModel$ = new Subject();
onReloadModel$ = this._onReloadModel$.asObservable();
private _isRemindersLoaded$ = new BehaviorSubject(false);
isRemindersLoaded$: Observable = this._isRemindersLoaded$.asObservable();
private _w: Worker;
private _reminders: Reminder[];
private _throttledShowNotification = throttle(60000, this._showNotification.bind(this));
constructor(
private readonly _projectService: ProjectService,
private readonly _globalSyncService: GlobalSyncService,
private readonly _persistenceService: PersistenceService,
private readonly _notifyService: NotifyService,
private readonly _snackService: SnackService,
private readonly _taskService: TaskService,
private readonly _noteService: NoteService,
private readonly _imexMetaService: ImexMetaService,
) {
}
init() {
if (typeof Worker !== 'undefined') {
this._w = new Worker('./reminder.worker', {
constructor(props) {
super(props);
this.throttledSetState = throttle(500, this.setState);
this.state = {
speciesListSearchTerm: null,
};
}
function updateRestartFn () {
if (currentOptions.value.throttle) {
debouncedRestart = throttle(currentOptions.value.throttle, baseRestart)
} else if (currentOptions.value.debounce) {
debouncedRestart = debounce(currentOptions.value.debounce, baseRestart)
} else {
debouncedRestart = baseRestart
}
}
return el
}
el = el.parentNode
}
return document
},
initFlowLoader() {
if (this.error) {
return
}
if (checkInView(this.$refs.state)) {
this.loadMore()
}
on(this.getTarget(), 'scroll', this.onScreenScroll)
},
onScreenScroll: throttle(200, function() {
if (this.error) {
return
}
if (this.noMore || !this.auto) {
off(this.getTarget(), 'scroll', this.onScreenScroll)
return
}
if (checkInView(this.$refs.state)) {
this.loadMore()
}
})
}
}
this.handleSize(size);
}
onCompileButtonClick = mode => {
this._clearCompileTimeout();
if (mode === CompileMode.Auto || mode === CompileMode.Manual)
this.updateCompilation();
}
onSettingsOptionChange = (key, value) => {
if (!this.state.compilerReady) return;
this.setState({ [key]: value }, key !== 'base64' ? this.updateCompilation : null);
}
handleSize = throttle(8, size => {
if (this.splitEditor) {
if (!this._cachedClientRect)
this._cachedClientRect = ReactDOM.findDOMNode(this.splitEditor).getBoundingClientRect();
const { width, height } = this._cachedClientRect;
const pos = (size ? size / width : this.state.splitPosition);
const primaryWidth = width * pos;
this.setState({
inputEditorWidth: Math.ceil(primaryWidth),
outputEditorWidth: Math.ceil(width - primaryWidth - SplitGripWidth),
editorsHeight: height - 160,
splitPosition: pos,
});
this.splitEditor.setSize(