# A simple zoom slider

**URL:** <https://talk.observablehq.com/t/a-simple-zoom-slider/8585>\
**Category:** Help\
**Created:** [December 10, 2023, 9:06pm UTC](https://talk.observablehq.com/t/a-simple-zoom-slider/8585 "2023-12-10T21:06:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgish](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kgish/32/8188_2.png) [@kgish](https://talk.observablehq.com/u/kgish)\
**Post date:** [December 10, 2023, 9:06pm UTC](https://talk.observablehq.com/t/a-simple-zoom-slider/8585/1 "2023-12-10T21:06:15Z")

</div>

I’ve created a force directed graph which I can manipulate using various sliders.

I would also like to use a slider with zoom levels to trigger zooming in and out, centered in the middle of the svg rectangle.

The default zoom works fine, but I would like to disable all event handling like mouse wheel, double click, etc and only a zoom slider can be used.

However, pan should still be allowed.

What’s the best way to do this?

---

<div class="post-metadata">

**Author:** ![MarioDelgadoSr](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mariodelgadosr/32/1828_2.png) [@MarioDelgadoSr](https://talk.observablehq.com/u/MarioDelgadoSr)\
**Post date:** [December 25, 2023, 4:32am UTC](https://talk.observablehq.com/t/a-simple-zoom-slider/8585/2 "2023-12-25T04:32:22Z")

</div>

- Here’s one approach: [Programmatic Zoom / Mario Delgado | Observable](https://observablehq.com/d/23aacadb79a3ef68)
- Adopted from @mbostock’s [Programmatic Zoom / D3 | Observable](https://observablehq.com/@d3/programmatic-zoom)

---

<div class="post-metadata">

**Author:** ![kgish](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kgish/32/8188_2.png) [@kgish](https://talk.observablehq.com/u/kgish)\
**Post date:** [December 26, 2023, 12:56pm UTC](https://talk.observablehq.com/t/a-simple-zoom-slider/8585/3 "2023-12-26T12:56:20Z")

</div>

Nice, thanks!

---

<div class="post-metadata">

**Author:** ![kgish](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/kgish/32/8188_2.png) [@kgish](https://talk.observablehq.com/u/kgish)\
**Post date:** [January 2, 2024, 8:16am UTC](https://talk.observablehq.com/t/a-simple-zoom-slider/8585/4 "2024-01-02T08:16:01Z")

</div>

How can I download the original example code?

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [January 2, 2024, 10:56am UTC](https://talk.observablehq.com/t/a-simple-zoom-slider/8585/5 "2024-01-02T10:56:24Z")

</div>

@kgish You can view each notebook cell’s code by clicking into the left-hand side.

Alternatively you can enable “Safe mode” where only the code is visible. Go to the notebook menu in the top right, then select “View” \> “Enable safe mode”:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/a/abadb282316b3140a2a4067d47d3a1671efb7ecd.png)

Alternatively you can append “/safe” to the notebook URL.
