Firefox禁用浏览器缩放,但允许缩放元素缩放 [英] Firefox disable browser zoom but allow element zoom on pinch
问题描述
我有一个网站运行针对触摸屏运行Firefox(非常具体我知道,但它会有希望帮助一个解决方案)
在有问题的页面,我有一个d3地图,我' m尝试启用捏缩放,但是任何捏合手势都会导致Firefox为整个页面设置缩放。有没有办法防止页面缩放,并只允许地图放大?
I've got a site running aimed at touchscreens running Firefox (very specific I know, but it will hopefully help with a solution) On the page in question, I've got a d3 map that I'm trying to enable pinch zooming for, however any pinch gesture is causing Firefox to set the zoom for the whole page. Is there a way to prevent the page zooming and only allow the map to zoom?
这不是一个问题,如果我要修改Firefox配置设置,但我更喜欢
It's not an issue if I have to modify Firefox config settings but I'd prefer to avoid it and rely entirely on javascript if possible.
提前感谢您
推荐答案
您可以使用 viewport metatag 和 Hammer .js
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
这将禁用默认的浏览器缩放。
This will disable the default browser zoom.
然后,您可以使用 Hammer.js 捕获手势事件然后将其传递到您的D3.js代码以缩放您的地图
You can then use Hammer.js to capture gesture events which you will then pass to your D3.js code to zoom your map
这篇关于Firefox禁用浏览器缩放,但允许缩放元素缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!