javascript:可以使用 touchmove 来模拟 iPhone 上的鼠标悬停吗?

发布于 2024-12-04 04:43:43 字数 315 浏览 1 评论 0原文

理想情况下,有一种方法可以在 iphone/ipad 上使用 touchstart 和 touchmove 来模拟以下 javascript 的鼠标悬停图像映射功能:

http ://www.netzgesta.de/mapper/

我希望允许 iphone/ipad 用户触摸地图,突出显示他们触摸过的国家/地区,当他们将手指拖动到其他国家/地区时,这些国家/地区依次点亮向上,就像他们通过桌面浏览器使用鼠标悬停一样。

想法、想法?这可能吗?

Ideally there is a way to mimic the mouseover imagemap capabilities of the following javascript using touchstart and touchmove on the iphone/ipad:

http://www.netzgesta.de/mapper/

I wish to allow the iphone/ipad user to touch the map, have the country they've touched highlight, and when they drag their finger over other countries, those countries in turn light up, just as they would via a desktop browser using mouseover.

Ideas, thoughts? Is this even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过去的过去 2024-12-11 04:43:43

您可以尝试使用touchesBegan和touchesMoved来获取触摸的坐标,然后检查它们是否在地图上的对象内。要获取这些坐标,请使用:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchedPoint = [touch locationInView:self.view];
    //now you can use touchedPoint.x and touchedPoint.y for the coordiantes of the touched point.
}

类似地,您可以使用

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchedPoint = [touch locationInView:self.view];
}

也存在touchesEnded 和touchesCancelled。您可以使用这些来获取触摸的坐标,然后由您来解释这些点。您可以为要滚动的每个部分绘制近似矩形,这将使这变得相当简单,但如果您有一个具有 javascript 地图的预期功能的地图,您将需要更复杂的形状,并且必须使用其他方法来定义形状。

You might try using touchesBegan and touchesMoved to get the coordinates of your touch and then check to see if those are within the object on your map. To get these coordinates, use:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchedPoint = [touch locationInView:self.view];
    //now you can use touchedPoint.x and touchedPoint.y for the coordiantes of the touched point.
}

Similarly, you can use

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint touchedPoint = [touch locationInView:self.view];
}

There also exists touchesEnded and touchesCancelled. You can use these to get the coordinates of the touch, afterwards it is up to you to interpret these points. You could approximate rectangles for each section to be rolled over which would make this rather simple, but if you have a map with the intended functionality as the javascript map, you would need more complex shapes and would have to use other methods to define the shape.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文