use serde::{Deserialize, Serialize};
use crate::Vec2;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DragEvent {
kind: DragEventKind,
start_location: Vec2<f64>,
location: Vec2<f64>,
}
impl DragEvent {
pub fn kind(&self) -> DragEventKind {
self.kind
}
pub fn start_location(&self) -> Vec2<f64> {
self.start_location
}
pub fn location(&self) -> Vec2<f64> {
self.location
}
pub fn translation(&self) -> Vec2<f64> {
self.location - self.start_location
}
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum DragEventKind {
Updated,
Ended,
}