Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifier 核心說明 #11

Open
hinablue opened this issue May 12, 2014 · 2 comments
Open

Modifier 核心說明 #11

hinablue opened this issue May 12, 2014 · 2 comments

Comments

@hinablue
Copy link
Owner

#1 有提過 Modifier 的一些使用說明,不過最近一次官方更新,有些東西被棄用了(至於要怎麼取代,或是用什麼取代,就沒有特別提及

Modifier 核心

之前已經說過,他是一個類似效果套用的模組,

<div class="famous-surface" style="/* Modifier 會在這裡發生 */"></div>

其他的就不再贅述,先來看看可以使用的屬性與方法,

方法

  • transformFrom 設定變形
  • opacityFrom 設定透明度
  • originFrom 設定對齊定位
  • sizeFrom 設定尺寸

以下方法將來會棄用

  • setTransform
  • setOpacity
  • setOrigin
  • setSize
  • halt
  • getTransform
  • getFinalTransform
  • getOpacity
  • getOrigin
  • getSize

棄用超多的(雖然目前還可用,不過如果有用到,得改掉才行。基本上,在 Modifier 原始碼當中,對於棄用這些方法,都有給建議的替代方式,不過大多都是說,

叫你去原先設定 Transform 的物件去拿

我不知道這樣是好是壞,對於 Modifier 來說,他不用扛那麼多東西在身上或許是好,不過對於開發者來說,還得多準備一個地方來放對應的 Transform 或是 TransitionableTransform 其實也挺傷腦筋的。

@andmix
Copy link

andmix commented Nov 11, 2014

origin, align 实际使用 似乎可以取任何数值, 做slide等插件很方便 ,resize时也会自动适应, 请问这样做官方推荐吗?

@hinablue
Copy link
Owner Author

@andmix

官方並沒有特別推薦該怎麼做,所以要這麼做也不是不可以。
不過自適應你可能需要考量效能問題(像是在瀏覽器中所演發的 reflows, repaints 爾等的結果

可以取任何數值有一定的風險存在,由於會自適應,所以在某些情況下,你無法由這兩個數值取得真實尺寸,這是你必須考慮到的地方。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants