Improve document zooming to work based on nice steps (#336)

* Improve document zooming to work based on nice steps

* Code review improvements
This commit is contained in:
Keavon Chambers
2021-08-10 16:21:18 -07:00
parent 1ee94f41f0
commit a570ff22e8
9 changed files with 97 additions and 45 deletions

View File

@@ -253,11 +253,25 @@ pub fn export_document() -> Result<(), JsValue> {
/// Sets the zoom to the value
#[wasm_bindgen]
pub fn set_zoom(new_zoom: f64) -> Result<(), JsValue> {
pub fn set_canvas_zoom(new_zoom: f64) -> Result<(), JsValue> {
let ev = MovementMessage::SetCanvasZoom(new_zoom);
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}
/// Zoom in to the next step
#[wasm_bindgen]
pub fn increase_canvas_zoom() -> Result<(), JsValue> {
let ev = MovementMessage::IncreaseCanvasZoom;
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}
/// Zoom out to the next step
#[wasm_bindgen]
pub fn decrease_canvas_zoom() -> Result<(), JsValue> {
let ev = MovementMessage::DecreaseCanvasZoom;
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}
/// Sets the rotation to the new value (in radians)
#[wasm_bindgen]
pub fn set_rotation(new_radians: f64) -> Result<(), JsValue> {