2013-08-22 36 views
3

我有一些形狀,用paper.path()創建,我想填充(用於單擊和拖動)和透視。但是當我將不透明度設置爲零時,形狀的輪廓(中風)以及內部消失。無論如何,只有我的形狀的內部有不透明度0?Raphael中風不透明

兩件事情我已經試過:

(1)設置 「中風不透明度」 屬性。這看起來有幫助,例如噸這裏仍然是不可見的:

var paper = Raphael(0, 0, "100%", "100%")var t = paper.path(["M", 100, 100, "L", 150, 150, "L",  100, 300, "L", 100, 100]).attr({stroke : "black", 
                        fill :  "white", 
                        opacity :  0, 
                        "stroke- opacity" : 1}) 

(2)不透明度創建-1概述了我的形狀的未填充的輪廓,並與填充的但透明的原稿一起顯示這些。這有效,但拖拉很痛苦。

有更好的解決方案嗎?

回答

3

如果您只是想使填充透明,則應該使用填充不透明度而不是不透明度。或者,您可以將填充設置爲無。

var t = paper.path('M100 100L150 150L100 300L100 100').attr({ 
    'stroke': 'black', 
    'fill': 'white', 
    'fill-opacity': 0, 
    'stroke-width': 15, 
    'stroke-opacity': 0.5, 
    'stroke-linecap': 'round', 
    'stroke-linejoin': 'round' 
}); 

var t = paper.path('M100 100L150 150L100 300L100 100').attr({ 
    'stroke': 'black', 
    'fill': 'none', 
    'stroke-width': 15, 
    'stroke-opacity': 0.5, 
    'stroke-linecap': 'round', 
    'stroke-linejoin': 'round' 
}); 

至於拖,聽起來像是你應該調整pointer-events財產。也許指針事件:'全部'會給你你正在尋找的結果。

0

http://jsfiddle.net/uWKdx/

var paper = Raphael(0, 0, 400, 400); 
var t = paper.path('M100 100L150 150L100 300L100 100').attr({ 
    'stroke': 'black', 
    'fill': 'white', 
    'opacity': 1, 
    'stroke-width': 15, 
    'stroke-opacity': 0.5, 
    'stroke-linecap': 'round', 
    'stroke-linejoin': 'round' 
}); 

通知,在聯通版行程不透明度設置爲0,顯示元素填充:

http://jsfiddle.net/uWKdx/1/

關於拖動......什麼是錯的它?