meteor2013
V2EX  ›  问与答

如何限制一个 Div 不能移出另一个 SVG 区域外呢?

  •  1
     
  •   meteor2013 · Aug 21, 2015 · 1743 views
    This topic created in 4109 days ago, the information mentioned may be changed or developed.
    A 这个 DIV 自由运动,但要限制它只能在 B 范围( B 是一个 SVG 的圈)内移动?
    6 replies  •  2015-08-21 11:32:51 +08:00
    sunjourney
    sunjourney
    Aug 21, 2015 via iPhone
    1
    写 js ,要不就 overflow hide
    meteor2013
    meteor2013
    OP
    Aug 21, 2015 via iPhone
    2
    @sunjourney 限制 A, 不然它移出 B ,不是隐藏
    ljbha007
    ljbha007
    Aug 21, 2015
    3
    @meteor2013 只能 javascript 咯
    lwbjing
    lwbjing
    Aug 21, 2015
    4
    只能算算 a 的 4 个点与 b 圆弧上点的碰撞了。。
    meteor2013
    meteor2013
    OP
    Aug 21, 2015 via iPhone
    5
    @lwbjing 能说具体点吗?
    w88975
    w88975
    Aug 21, 2015
    6
    @meteor2013 用你的 div 的四个角坐标,分别去计算每个角是否在 SVG 绘制出来的圆内,这个需要用到三角函数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1573 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:29 · PVG 00:29 · LAX 08:29 · JFK 11:29
    ♥ Do have faith in what you're doing.