Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snap interaction #204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/interaction/RSnap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {default as Snap} from 'ol/interaction/Snap';
import {default as RBaseInteraction} from './RBaseInteraction';

/**
* @propsfor RSnap
*/
export interface RSnapProps {
/** Snap tolerance in pixels
* @default 10 */
pixelTolerance?: number;
}

/** Snap */
export default class RSnap extends RBaseInteraction<RSnapProps> {
protected static classProps = ['pixelToleranc'];
ol: Snap;

createOL(props: RSnapProps): Snap {
this.classProps = RSnap.classProps;
return new Snap(
Object.keys(props)
.filter((p) => this.classProps.includes(p))
.reduce((ac, p) => ({...ac, [p]: props[p]}), {})
);
}
}
1 change: 1 addition & 0 deletions src/interaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export {default as RPinchRotate} from './RPinchRotate';
export {default as RPinchZoom} from './RPinchZoom';
export {default as RKeyboardPan} from './RKeyboardPan';
export {default as RKeyboardZoom} from './RKeyboardZoom';
export {default as RSnap} from './RSnap';
Loading