CSSæšæºã®æ©èœã䜿çšããããšæã£ãããšã¯ãããŸããããã¹ãŠã®ãã©ãŠã¶ã§ãµããŒããããŠããããã§ã¯ãªãããã䜿çšããŸããã§ãããïŒ ããã«æªãããšã«ããã¹ãŠã®ãã©ãŠã¶ãŒã§ãµããŒããããŠããŸããããã°ããããççŸããŠãããããŸã£ããäºææ§ããããŸãããïŒ ãã£ãšããªãã¯ããã«åºããããã®ã§ã HoudiniãããèŠãããšããå§ãããŸãã
ããã¯æ°ããW3Cã¯ãŒãã³ã°ã°ã«ãŒãã§ãããäžèšã®åé¡ãæä¹ çã«è§£æ±ºãããšããéå¿çãªã¿ã¹ã¯ãæã£ãŠããŸãã ããã¯ãAPIã®æ°ããã»ããã®å©ããåããŠè¡ãããäºå®ã§ããããã«ãããéçºè ã¯åããŠCSSãç¬ç«ããŠæ¡åŒµã§ãããã©ãŠã¶ãŒãšã³ãžã³ã®äœæ¥äžã«ã¬ã€ã¢ãŠããäœæããŠã¹ã¿ã€ã«ãé©çšããããã»ã¹ã«æ¥ç¶ããããŒã«ãæäŸã§ããŸãã
ãããããããã®çŽæã®èåŸã«ã¯æ£ç¢ºã«äœããããŸããïŒ ããã¯è¯ãã¢ã€ãã¢ã§ããïŒ ãããŠãäžèšã®ãã¹ãŠããéçºè ãä»æ¥ããã³ææ¥ããµã€ããäœæããã®ã«ã©ã®ããã«åœ¹ç«ã¡ãŸããïŒ
ããããã¹ãŠã®è³ªåã«çããããšããŸãã ããããæåã«ãä»æ¥ã®çŸåšã®åé¡ãšãããã解決ããå¿ èŠæ§ãæ確ã«ããŸãã ãããŠãHoudiniãããããã©ã®ããã«æ¯æŽã§ãããã«ã€ããŠèª¬æããéçºäžã®æãå°è±¡çãªæ©èœãããã€ãèŠãŠãããŸãã çµè«ãšããŠãéçºã³ãã¥ããã£ãHoudiniãããžã§ã¯ãã®å®è£ ãã©ã®ããã«æ¯æŽã§ãããã«ã€ããŠãå€ãã®ææ¡ãããŸãã
Houdiniã¯ã©ã®ãããªåé¡ã解決ããããšããŠããŸããïŒ
æ°ããCSSæ©èœãæ®åãããããã«èšäºãæžãããããã¢ã¢ããªã±ãŒã·ã§ã³ãäœæãããã³ã«ãå¿ ç¶çã«æ¬¡ã®ãããªã³ã¡ã³ããåãåããŸãã ç§ãã¡ããããããã«10幎é䜿çšã§ããªãããšã¯äœãšæ®å¿µãªããšã§ããããã ãã®ãããªã³ã¡ã³ãã¯å»ºèšçã§ã¯ãªããéåžžã«è¿·æã§ãããéçºè ã®æ°åã¯ç解ã§ããŸãã ãã®ãããåºç¯ãªã€ãããŒã·ã§ã³ã«ã¯æ°å¹ŽããããŸãã ãããŠããŠã§ãã®æŽå²ãç§ãã¡ã«æããŠãããäž»ãªçç±ã¯ãæšæºåããã»ã¹ãéããŠæä»çã«æ°ããCSSæ©èœãååŸããããšã§ãã
æšæºåããã»ã¹ã®æ®µé
æšæºåã«å察ããããšã¯ãããŸããããæéãããããããŸãïŒ ããšãã°ã2009幎ã«flexboxãå°å ¥ãããŸããããéçºè ã¯ããã©ãŠã¶ãŒã®ãµããŒããäžååãªããããŸã 䜿çšã§ããªããšèª¬æããŠããŸãã 幞ããªããšã«ãã»ãšãã©ãã¹ãŠã®ææ°ã®ãã©ãŠã¶ãŒã¯èªåçã«æŽæ°ãããããããã®åé¡ã¯åŸã ã«è§£æ¶ãããŠããŸãã ãããããã®å Žåã§ããæ©èœã®æäŸãšããã䜿çšããäžè¬çãªææã®éã«ã¯åžžã«é 延ããããŸãã èå³æ·±ãããšã«ããã®ç¶æ³ã¯Webã®ãã¹ãŠã®é åã§èŠãããããã§ã¯ãããŸããã ããšãã°ãJavaScriptãšæ¯èŒããŸãã
ããªãã£ã«ã®å®è£ æé
ãã®å Žåãã¢ã€ãã¢ãçãŸããŠããäœæ¥ã«äœ¿çšããããŸã§ã«æ°æ¥ãããå ŽåããããŸãã ããšãã°ãå®çšŒåç°å¢ã§ã¯æ¢ã«
async/await
é¢æ°ã䜿çšããŠããŸããããã®æ©èœã¯ã©ã®ãã©ãŠã¶ãŒã«ããŸã å®è£ ãããŠããŸããïŒ
確ãã«ãããªãã¯äž¡æ¹ã®ã³ãã¥ããã£ã®ã ãŒãã«å€§ããªéããããããšã«æ°ã¥ããŸããã JSã³ãã¥ããã£ã§ã¯ãç©äºãããŸãã«ãæ¥éã«å€åãããšäžæºãèšãèšäºãèªã¿ãŸãã ãŸããCSSã§ã¯ãæ°è£œåã䜿çšããåã«å€ãã®æéãæ®ã£ãŠããããã誰ããæ°è£œåã«ã€ããŠåŠã¶ããšã®ç¡çãã«ã€ããŠåããŸãã
ããã§ã¯ããªãCSSããªãã£ã«ããã£ãšäœæããªãã®ã§ããïŒ
äžèŠãããã¯æãããªè§£æ±ºçã§ãã åªããããªãã£ã«CSSã®ãããã§ãJavaScriptã®ããã«ããŒã¹ãéããªããŸãããïŒ æ²ããããªãããã»ã©åçŽã§ã¯ãããŸããã CSSã«ããªãã£ã«ãåã蟌ãã®ã¯éåžžã«é£ãããå€ãã®å Žåãããã©ãŒãã³ã¹ãå®å šã«ã¯ã©ãã·ã¥ãããã«åã蟌ãããšã¯ã§ããŸããã
JavaScriptã¯åçèšèªã§ãããããJSã§JSã®ããªãã£ã«ãäœæã§ããŸãã ãã®ä¿¡ããããªãã»ã©ã®æ¡åŒµæ§ã¯ããã®åçãªæ§è³ªã®çµæã§ãã ãŸããCSSã䜿çšããŠç¬èªã®ããªãã£ã«ãäœæããããšã¯ã»ãšãã©ãããŸããã ãã«ã段éã§ãCSSã³ãŒããCSSïŒãã©ã³ã¹ãã€ã«ïŒã³ãŒãã«ã³ã³ãã€ã«ã§ããå ŽåããããŸãïŒ PostCSSã¯ãããè¡ããŸãïŒã ãã ããDOMæ§é ã«äŸåãããã®ããŸãã¯èŠçŽ ã®äœçœ®ãã¬ã€ã¢ãŠãã«ããªãã£ã«ã䜿çšããå Žåã¯ãã¯ã©ã€ã¢ã³ãåŽã§ããªãã£ã«ããžãã¯ãå®è¡ããå¿ èŠããããŸãã æ®å¿µãªããããã©ãŠã¶ã¯ãã®ã¿ã¹ã¯ãç°¡åã«ããŸããã
以äžã¯ãHTMLããã¥ã¡ã³ãã®åä¿¡ããç»é¢äžã®ãã¯ã»ã«ã®è¡šç€ºãŸã§ã®ãã©ãŠã¶ããã»ã¹ã®åºæ¬å³ã§ãã JavaScriptãçµæã«åœ±é¿ãäžããããšãã§ããéãã¹ãããã匷調衚瀺ãããŠããŸãã
ãã©ãŠã¶ã¬ã³ããªã³ã°ãã€ãã©ã€ã³ãžã®JavaScriptã¢ã¯ã»ã¹
ããªãæãåçã éçºè ã¯ãHTMLãšCSSã解æãããããDOMããã³CSSãªããžã§ã¯ãã¢ãã« ïŒCSSOMïŒã«å€æããããã»ã¹ãå¶åŸ¡ããŸããã ã«ã¹ã±ãŒããå¶åŸ¡ããŸããã DOMã®èŠçŽ ã®ã¬ã€ã¢ãŠããéžæããããã»ã¹ãå¶åŸ¡ããã®ã§ã¯ãªãã衚瀺ããããšãã®è²ãå¶åŸ¡ããã®ã§ã¯ãããŸããã æåŸã«ãäœæ²å®¶ïŒã³ã³ããžããïŒã®æäœã«åœ±é¿ã¯ãããŸããã DOMã®ã¿ãå®å šã«ããªãã«åŸå±ããŸãã CSSOMã«ã¯ããçšåºŠã®åœ±é¿ããããŸãããHoudiniã®ãµã€ãã«ãããšããã®æé ã¯ãæ確ã«å®çŸ©ãããŠãããããã©ãŠã¶ãŒã«ãã£ãŠç°ãªããéèŠãªæ©èœããããŸããããšã®ããšã§ãã ããšãã°ãä»æ¥CSSOMã¯ã¯ãã¹ãªãªãžã³ã®ã¹ã¿ã€ã«ã·ãŒãã®ã«ãŒã«ã衚瀺ãããç解ã§ããªãå Žåã¯ã«ãŒã«ãåé€ããŸãã ããã¯ãæ©èœãè¿œå ããããªãã£ã«ãäœæããå ŽåãCSSOMããã€ãã¹ããããšãäœåãªããããããšãæå³ããŸãã DOMãä»ããŠ
<style>
ããã³/ãŸãã¯
<link rel="stylesheet">
ã¿ã°ãèŠã€ããŠãããCSSãèªåã§ååŸããŠè§£æããå€æããŠããDOMã«è¿œå ãçŽãå¿ èŠããããŸãã
ãã¡ãããDOMã®æŽæ°ã¯éåžžããã©ãŠã¶ãŒããã¹ãŠã®ã¹ãããïŒã«ã¹ã±ãŒãããã³ãã¬ãŒããã«ã©ãŒãªã³ã°ãã¬ã€ã¢ãŠãïŒãå床å®è¡ããå¿ èŠãããããšãæå³ããŸãã
ãã©ãŠã¶ã¬ã³ããªã³ã°ãã€ãã©ã€ã³ã§JavaScriptããªãã£ã«ã䜿çšãã
ããŒãžã®å®å šãªåæç»ãããã©ãŒãã³ã¹ã«ããŸã圱é¿ãäžããªããšèããŠããå Žåã¯ããããçºçããé »åºŠãèŠããŠãããŠãã ããã ã¹ã¯ããŒã«ããŠã£ã³ããŠã®ãµã€ãºå€æŽãããŠã¹ã®ç§»åãããŒã¹ãããŒã¯ãªã©ã®ã€ãã³ãã«å¿ããŠãã€ãŸãå€æŽãå ããŠããªãã£ã«ããžãã¯ãå®è¡ããå¿ èŠãããå Žåããµã€ãã®åäœã¯èããé ããªããŸãã ãã¹ãŠã®ææ°ã®CSSããªãã£ã«ã«ç¬èªã®CSSããŒãµãŒãšã«ã¹ã±ãŒãããžãã¯ãå«ãŸãããšæ³åãããšããã¹ãŠãããã«æãèŠããŸãã ãŸãããããã¯éåžžã«è€éãªã³ã³ããŒãã³ãã§ãããããããªãã£ã«ã¯éåžžã«å€§ããããéåžžã«éèŠã§ãã
èšãããããšãã¹ãŠããŸãšãããšããã©ãŠã¶ãŒãæå³ããŠããªãããšïŒãã©ãŠã¶ãŒã«ãã£ãŒãããCSSãå«ãïŒã匷å¶çã«å®è¡ããããå ŽåãDOMã®èªå·±ä¿®æ£ã䜿çšããŠãããã ãŸãæ¹æ³ãèããå¿ èŠããããŸãã ãã€ãã©ã€ã³ã®ä»ã®ã¹ããŒãžã«ã¯ã¢ã¯ã»ã¹ã§ããŸããã
ãããããªãå éšãã©ãŠââã¶ãŒãšã³ãžã³ãå€æŽããå¿ èŠãããã®ã§ããããïŒ
ç§ã®æèŠã§ã¯ãããã¯èšäºå šäœã®äžã§æãéèŠãªåé¡ã§ãã ãããã£ãŠããã®ç¹ã«å°éãããããã£ãããšææ ®æ·±ãèªã¿é²ããŠãã ããïŒ
åã®ã»ã¯ã·ã§ã³ã®åŸãããªãã®äžäººãèããŸããïŒãç§ã¯ãããå¿ èŠãšããŸããïŒ ç§ã¯éåžžã®WebããŒãžãå®è¡ããŠããã ãã§ããã©ãŠã¶ãŒã®å éšããããã³ã°ããããéåžžã«èŽ æ²¢ãªå®éšçãŸãã¯è¶ è¿ä»£çãªããšãããããšã¯ããŠããŸãããã ãã®ãããªèãã«ããªãã蚪ãããªããç§ã¯ããªãããã®ããã¹ããä»ã®ãšãã延æããããªããè¿å¹ŽãŠã§ããµã€ããäœæããããã«äœ¿çšããæè¡ã泚ææ·±ãç 究ããããšã䞻匵ããŸãã ãã©ãŠã¶ã§ã¹ã¿ã€ã«ãé©çšããããã»ã¹ã«ã¢ã¯ã»ã¹ããããšããé¡æã¯ã掟æãªãã¢ãäœæããããšã§ã¯ãªããéçºè ãšãã¬ãŒã ã¯ãŒã¯ã®äœæè ã«æ¬¡ã®2ã€ã®ããšãããæ©äŒãäžããããšã«ã€ãªãããŸãã
- ãã©ãŠã¶éã®ã¹ã ãŒãºãªéãã
- 人ã ãä»æ¥ãããã䜿çšã§ããããã«ãããªãã£ã«ã䜿çšããŠæ°ããæ©èœãçºæãããè¿œå ãããããŸãã
jQueryã䜿çšããããšãããå Žåã¯ããã®æ©èœã䜿çšããããšã§ããã«ã¡ãªãããåŸãããŸãã ããã¯ãã»ãšãã©ãã¹ãŠã®ææ°ã®ããã³ããšã³ãã©ã€ãã©ãªãšãã¬ãŒã ã¯ãŒã¯ãæ¯æããäž»ãªè°è«ã®1ã€ã§ãã ããšãã°ãGitHubã§æã人æ°ã®ãã5ã€ã®JSããã³DOMãªããžããªïŒAngularJSãD3ãjQueryãReactãããã³EmberïŒã¯ããã©ãŠã¶éã®éããæ»ããã«ããããã«å€å€§ãªåªåãæã£ãŠããŸãã ãããã®åãããžã§ã¯ãã¯ãæèšã®ããã«æ©èœããåäžã®APIãæäŸããŸãã
次ã«ãCSSãšãããã®ãã¹ãŠã®ã¯ãã¹ãã©ãŠã¶ãŒã®åé¡ã«ã€ããŠèããŸãã åºãäºææ§ããããšäž»åŒµããŠããBootstrapãFoundationã®ãããªäžè¬çãªãã¬ãŒã ã¯ãŒã¯ã§ãããå®éã«ã¯ã¯ãã¹ãã©ãŠã¶ã®ãã°ã®åé¡ã解決ããŸãã-ããããåã«åé¿ããŸãã ããããCSSã®ãããã®ãã°ã¯ãã¹ãŠãéå»ã®æçã ãã§ã¯ãããŸããã ä»æ¥ã§ãã flexboxã®ãããªæ°ãããã³ãã¬ãŒãã¢ãžã¥ãŒã«ã䜿çšããŠããã«ãããããããéäºææ§ã«åžžã«çŽé¢ããŠããŸãã CSSããããã£ã䜿çšã§ãããã¹ãŠã®ãã©ãŠã¶ãŒã§åçã«ããŸãæ©èœãããšç¢ºä¿¡ããŠããå Žåãéçºè ãã©ãã»ã©ç°¡åã«ç掻ã§ãããæ³åããŠã¿ãŠãã ããã ãŸãã¯ãããã°ã§èªãã ããäŒè°ãäŒè°ã§èãããã¹ãŠã®çŽ æŽããããã¥ãŒã¹ïŒ ã°ãªãã ã ã¢ã³ã«ãŒãã€ã³ãã ã¹ãã£ãããŒããžã·ã§ãã³ã°ãªã©ïŒãèŠããŠãããŠãã ããã ãã€ãã£ãCSSæ©èœãšåããããç°¡åã«ãä»ãããããã䜿çšã§ããæ¹æ³ãæ³åããŠãã ããã ãã®ããã«ã¯ãGitHubããã³ãŒããã³ããŒããã ãã§ãã
ããã¯ãã¹ãŠãHoudiniéçºããŒã ã®å€¢ã§ãã ããã圌ããåµé ããããšããŠããæªæ¥ã§ãã ãŸããCSSããªãã£ã«ã®äœæãå®éšçãªæ©èœã®éçºãèšç»ããŠããªãå Žåã§ããããããä»ã®äººã«ãããããŠãããããã§ãããã çµå±ã®ãšããããã®ãããªããªãã£ã©ãçŸããã°ã誰ãããã®æ©æµãåããã§ãããã
Houdiniã§çŸåšéçºäžã®æ©èœã¯äœã§ããïŒ
ãã©ãŠã¶ãã€ãã©ã€ã³ã®è¡šç€ºããŒãžãžã®ãšã³ããªãã€ã³ããéåžžã«å°ãªãããšãäžã§è¿°ã¹ãŸããã å®éãããã¯DOMã§ãããäžèŠãããšCSSOMã§ãã HoudiniéçºããŒã ã¯ãéçºè ã«ãã€ãã©ã€ã³ã®ä»ã®æ®µéãžã®ã¢ã¯ã»ã¹ãåããŠæäŸããããã€ãã®æ°ããä»æ§ãå°å ¥ããŸããã ãããã®ä»æ§ã¯å³ã«åæ ãããŠããŸãïŒèšç»ãããŠããŸããããŸã å®è£ ãããŠããªããããç°è²ã§åŒ·èª¿è¡šç€ºãããŠããŸãïŒã
æ°ããHoudini Visual Pipelineä»æ§
次ã®ã»ã¯ã·ã§ã³ã§ã¯ããããã®æ°ããä»æ§ã®ãããããç°¡åã«èŠãŠããã®æ©èœãåæããŸãã ãã®èšäºã§ã¯å€ãã®ä»æ§ã«ã€ããŠèšåããŠããŸãããããããžã§ã¯ããªããžããªã§å®å šãªãªã¹ããèŠã€ããããšãã§ããŸã ã
CSS解æAPI
ãã®ä»æ§ã¯ãŸã å®è£ ãããŠããªãããã以äžã®ãã¹ãŠãå€æŽãããå¯èœæ§ããããŸãã åºæ¬çãªèãæ¹ã¯ãéçºè ãCSSããŒãµãŒãæ¡åŒµããæ°ãããã¶ã€ã³ãéç¥ã§ããããã«ããããšã§ãã ããšãã°ãæ°ããã¡ãã£ã¢ã«ãŒã«ãæ°ããæ¬äŒŒã¯ã©ã¹ããã¹ãã
@extends
ã
@apply
ãªã©ã«ã€ããŠã¯ãããŒãµãŒãããããæ€åºãããšããã«ãããããCSSOMã®é©åãªå Žæã«é 眮ããããããããããšã¯ã§ããŸããã
CSSããããã£ãšå€API
CSSã«ã¯æ¢ã«ã«ã¹ã¿ã ããããã£ããããç§ã¯ããããæäŸããæ©èœãæ¬åœã«å¥œãã§ãã æ°ããAPIã¯ãåãè¿œå ããããšã§ãã®æ©èœãããé«ãã¬ãã«ã«åŒãäžããŸãã ããã«ã¯å€ãã®å©ç¹ããããŸãããæãéèŠãªã®ã¯ãåã®å©ããåããŠãéçºè ãè²ã®ç§»è¡ãšã«ã¹ã¿ã ããããã£ã®ã¢ãã¡ãŒã·ã§ã³ãå®è£ ã§ããããšã§ãïŒä»æ¥ã§ã¯äžå¯èœã§ãïŒã
äŸãåç §ããŠãã ããã
body { --primary-theme-color: tomato; transition: --primary-theme-color 1s ease-in-out; } body.night-theme { --primary-theme-color: darkred; }
night-theme
ã¯ã©ã¹ã
<body>
ãšã¬ã¡ã³ãã«è¿œå ããã
--primary-theme-color
ããããã£ã®å€ãåç §ããããŒãžäžã®ãã¹ãŠã®åã ã®ãšã¬ã¡ã³ãã®è²ã
tomato
ãã
darkred
åŸã ã«ç§»è¡ããŸãã ãããŸã§ã®ãšããããã®ããã«ã¯ãããããã£èªäœã®é·ç§»ãèšè¿°ããããšãã§ããªããããåèŠçŽ ã®è²é·ç§»ãæåã§èŠå®ããå¿ èŠããããŸãã
ãã®APIã®ãã1ã€ã®ææãªæ©èœã¯ãããã¯ãç»é²ããããšã§ããããã«ãããéçºè ã¯ã«ã¹ã±ãŒãæé ã®å®äºåŸã«èŠçŽ ã®ã«ã¹ã¿ã ããããã£ã®æçµå€ãå€æŽã§ããŸãã ããã¯ãããªãã£ã«ã®äœ¿çšã«é¢ããŠéåžžã«äŸ¿å©ã§ãã
CSSåä»ãOM
ãã®æ©èœã¯ãçŸåšã®CSSOMã®2çªç®ã®ããŒãžã§ã³ãšèŠãªãããšãã§ããŸãã çŸåšã®ã¢ãã«ã«é¢é£ããå€ãã®åé¡ã解決ããããã«èšèšãããŠãããæ°ãã解æAPIããã³ããããã£ãšå€ã®APIã«ãã£ãŠè¿œå ãããæ©èœãå«ãŸããŠããŸãã åä»ãOMã¯ãããã©ãŒãã³ã¹ãåäžãããããã«ãèšèšãããŠããŸãã CSSOMæååå€ãåä»ãJSè¡šçŸã«å€æãããšãé倧ãªããã©ãŒãã³ã¹ã®åé¡ãçºçããå¯èœæ§ããããŸãã
CSSã¬ã€ã¢ãŠãAPI
ãã®APIã«ãããéçºè ã¯ç¬èªã®ãããã¿ã€ãã³ã°ã¢ãžã¥ãŒã«ãäœæã§ããŸãã ãŸããããããã¿ã€ãã¢ãžã¥ãŒã«ããšã¯ã
display
ããããã£ã«æž¡ãããšãã§ãããã¹ãŠã®ãã®ãæå³ããŸãã ããã«ããã
display
ïŒ
flex
ã
display
ïŒ
table
ãªã©ã®ãã€ãã£ãã¢ãžã¥ãŒã«ã䜿çšããã®ãšåããããéãã¬ã€ã¢ãŠããäœæã§ããŸãã äŸã¯ãMasonryã©ã€ãã©ãªã§ãã éçºè ã¯ãCSSã ãã§ã¯å®è£ ã§ããªãè€éãªã¬ã€ã¢ãŠããäœæããå Žåããã®ãããªããŒã«ã«é Œããªããã°ãªããŸããã ãããŠããããã®ã¬ã€ã¢ãŠãã¯ãã¹ãŠéåžžã«å°è±¡çã«èŠããŸãããããã©ãŒãã³ã¹ã¯äœããç¹ã«æã匷åãªããã€ã¹ã§ã¯ããã§ã¯ãããŸããã
ã¢ãã¯ã¢ããAPIã¯ãã¬ã€ã¢ãŠãåïŒåŸã§CSSã§äœ¿çšãããïŒãååŸãã
registerLayout
ã¡ãœãããšããã¹ãŠã®ã¬ã€ã¢ãŠãããžãã¯ãå«ãJSã¯ã©ã¹ãæäŸããŸãã
registerLayout
䜿çšããŠç³ç©ã¿ãå®çŸ©ããæ¹æ³ã®ç°¡åãªäŸã次ã«ç€ºããŸãã
registerLayout('masonry', class { static get inputProperties() { return ['width', 'height'] } static get childrenInputProperties() { return ['x', 'y', 'position'] } layout(children, constraintSpace, styleMap, breakToken) { // Layout logic goes here. } }
ããã§ãã¹ãŠãç解ã§ããªããšæãããå Žåã§ããå¿é ããªãã§ãã ããã æãéèŠãªã®ã¯ã次ã®äŸã®ã³ãŒããèŠãŠãã ããã
masonry.js
ãã¡ã€ã«ãããŠã³ããŒãããŠãµã€ãã«è¿œå ãããšãCSSãåæ§ã®ã¹ã¿ã€ã«ã§èšè¿°ã§ãããã¹ãŠãæ©èœããŸãã
body { display: layout('masonry'); }
CSSãã€ã³ãã£ã³ã°API
ãã®APIã¯åã®ãã®ãšéåžžã«äŒŒãŠããŸãã
registerPaint
ãšåãããã«æ©èœãã
registerPaint
ã¡ãœãããæäŸããŸãã ãã®åŸãCSSã§
paint()
é¢æ°ã䜿çšããŠãããŒãµãŒãç»åãå¿ èŠãšãããã¹ãŠã®å Žæã§ãç»é²ãããååãæž¡ãããšãã§ããŸãã
è²ä»ãã®åãæãç°¡åãªäŸïŒ
registerPaint('circle', class { static get inputProperties() { return ['--circle-color']; } paint(ctx, geom, properties) { // Change the fill color. const color = properties.get('--circle-color'); ctx.fillStyle = color; // Determine the center point and radius. const x = geom.width / 2; const y = geom.height / 2; const radius = Math.min(x, y); // Draw the circle \o/ ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI, false); ctx.fill(); } });
CSSã§ã¯ã次ã®ããã«äœ¿çšã§ããŸãã
.bubble { --circle-color: blue; background-image: paint('circle'); }
ããã§ã
.bubble
ã®èæ¯ã«
.bubble
èŠçŽ ã衚瀺ãããŸãã ãã®åã¯ãèŠçŽ ã®äžå€®ã«é 眮ãããäœãèµ·ãã£ãŠããã®ãµã€ãºã«èª¿æŽãããŸãã
ã¯ãŒã¯ã¬ãã
説æãããŠããä»æ§ã®å€ãã«ã€ããŠããµã³ãã«ã³ãŒããæäŸãããŠããŸãïŒããšãã°ã
registerLayout
ããã³
registerPaint
ïŒã ãã®ã³ãŒãã¯ãã¯ãŒã¯ã¬ããã®ã¹ã¯ãªããã«é 眮ããå¿ èŠããããŸãã ãããã¯ãã¹ã¯ãªãããã¡ã€ã«ãã€ã³ããŒãããŠãã¡ã€ã³ã¹ã¬ããã«é¢ä¿ãªãèŠèŠåãã€ãã©ã€ã³ã®ããŸããŸãªæ®µéã§å®è¡ã§ããJSã³ãŒããå®è¡ã§ããããŠã§ãã¯ãŒã«ãŒãã«é¡äŒŒããŠããŸãã
é«æ§èœãç¶æããããã«ãã¯ãŒã¯ã¬ããã§èš±å¯ãããæäœã®çš®é¡ã¯å³ããå¶éãããŸãã
è€åã¹ã¯ããŒã«ãšã¢ãã¡ãŒã·ã§ã³
å ¬åŒã®ä»æ§ã¯ãŸã ååšããŠããŸããããããã¯Houdiniã®æãæåã§æåŸ ãããæ©èœã®1ã€ã§ã ã ã»ãšãã©ã®å Žåããããã®APIã«ãããã¡ã€ã³ã¹ã¬ããã®å€éšã®ãªã³ã«ãŒã®äœæ¥ç°å¢ã§ããžãã¯ãå®è¡ã§ããDOMèŠçŽ ã®éãããããããã£ã»ããã®å€æŽããµããŒããããŸãã ãã®ã»ããã«ã¯ããšã³ãžã³ã«ã¬ã€ã¢ãŠããŸãã¯ã¹ã¿ã€ã«ïŒå€æãéæ床ãã¹ã¯ããŒã«ã·ãããªã©ïŒã®åèšç®ã匷å¶ããããšãªããèªã¿åããŸãã¯å€æŽã§ããããããã£ã®ã¿ãå«ãŸããŸãã ããã«ãããããããŒãèŠå·®å¹æãã¹ã¯ããŒã«ãããšãã®ã¹ãã£ãã¯ãªã©ãã¹ã¯ããŒã«ãŸãã¯ãŠãŒã¶ãŒå ¥åã«åºã¥ããéåžžã«é«éãªã¢ãã¡ãŒã·ã§ã³ãå®è£ ã§ããŸãã GitHubã§ãããã®API ã䜿çšããæ¹æ³ã«ã€ããŠè©³ããèªãããšãã§ããŸãã
å ¬åŒã®ä»æ§ããªãã«ãããããããChromeéçºããŒã ã¯ãã§ã«å®éšãéå§ããŠããŸãã ãããã®APIãæäŸããããªããã£ãã䜿çšããŠã CSSã¢ã³ã«ãŒãã€ã³ããšã¹ãã£ãããŒããžã·ã§ãã³ã°ãå®è£ ããŸããã ããã¯ãHoudini APIãååã«é«éã§ããããããã«åºã¥ããŠChromeã§æ°ããæ©èœãäœæã§ããããšãæå³ããŸãã ãã®äºå®ã¯ããã€ãã£ãããŒã«ãšæ¯èŒããå Žåã®Houdiniã®ããã©ãŒãã³ã¹ã«é¢ããçåãæçµçã«è§£æ¶ããã¯ãã§ãã
Chromeã®å éšã¢ã»ã³ããªã䜿çšããŠäœæããããããªãèŠãããšãã§ããŸãã ã¹ã¯ããŒã«æã®ã¿ã€ãã«ã®åäœã瀺ããŸããããã¯ããã€ãã£ãã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³Twitterã«å®è£ ãããŠãããã®ãšåæ§ã§ãã ãœãŒã¹ã³ãŒããå©çšå¯èœã§ãã
ä»äœãã§ããŸããïŒ
ç§ãèšã£ãããã«ãHoudiniã¯ãŠã§ãéçºã«é¢ãããã¹ãŠã®äººã«ãšã£ãŠèå³ãããããã«æããŸãã ãã®ãããžã§ã¯ãã¯ãå°æ¥ã®ç§ãã¡ã®ç掻ã倧ãã«ä¿é²ããããšãã§ããŸãã ãããã®ä»æ§ãçŽæ¥äœ¿çšããããšããªãå Žåã§ãããããã«åºã¥ããŠæ§ç¯ãããããŒã«ã確å®ã«äœ¿çšã§ããŸãã ãããŠææ¥ã¯æããæªæ¥ã¯æ¥ãŸããããããã§ãããªãã®å€ãã«æãããããã¯è¿ãã§ãã ä»å¹Žãã·ãããŒã®äž»èŠãªãã©ãŠã¶éçºè ã®ä»£è¡šè ãéãŸã£ãŠã·ãããŒã®HoudiniããŒã ãšäŒããŸããããäœãã©ã®ããã«å®è£ ãããã«ã€ããŠæèŠã®çžéã¯ã»ãšãã©ãããŸããã§ããã ç§ã®ç¥ãéããå¯äžã®è³ªåã¯Houdiniã®äœæ¥ã®å®äºã®ã¿ã€ãã³ã°ã§ãã
ãã¹ãŠã®ãœãããŠã§ã¢éçºè ãšåæ§ã«ããã©ãŠã¶ã¡ãŒã«ãŒã¯è£œåã®æ°æ©èœã«ç¹ã«æ³šæãæãå¿ èŠããããŸãã ãããŠããã®ãããªåªå é äœã¯ãå€ãã®å Žåãæ°ããæ©èœã«å¯ŸããéèŠã®çšåºŠã«äŸåããŸãã ãã®ãããWebãµã€ãã®ã¹ã¿ã€ã«ãšã¬ã€ã¢ãŠãã®æ¡åŒµæ§ãæžå¿µãããå Žåãé·å¹Žã®æšæºåãåŸ ããã«æ°ããCSSæ©èœã䜿çšã§ããäžçã«äœã¿ããå Žåã¯ã䜿çšãããã©ãŠã¶ãŒã®éçºããŒã ã«é¢é£ä»ããããŠãã人ã«éç¥ããŠãã ããã
ãŸããã³ãã¥ããã£ã§æ°ãã補åãé©çšããããã®å¯èœãªæ¹æ³ãå ±æããããšã«ãããã±ãŒã¹ãæ¯æŽããããšãã§ããŸãã ã¹ã¿ã€ã«ãšã¬ã€ã¢ãŠãã§äœããããã®ããä»æ¥ããã®ãé£ãããŸãã¯äžå¯èœãªããšãæããŠãã ããã ãŠãŒã¹ã±ãŒã¹ã®èª¬æã¯GitHubã®äžéšã®ãã©ããã§å©çšã§ããŸããããã¡ããã¢ã€ãã¢ãå ±æããŠãã«ãªã¯ãšã¹ããäœæã§ããŸãã é©åãªããã¥ã¡ã³ãããªãå Žåã¯ãæ°ããããã¥ã¡ã³ããäœæã§ããŸãã
HoudiniéçºããŒã ïŒããã³W3Cå šäœïŒã¯ãWebéçºã³ãã¥ããã£ããæçãªå¿çãåŸãå¿ èŠããããŸãã ä»æ§ããã»ã¹ã«é¢äžãã人ã®å€ãã¯ãã©ãŠã¶ãšã³ãžãã¢ã§ãã å€ãã®å Žåã圌ãã¯ããã®Webéçºè ã§ã¯ãªããç§ãã¡ã®ç·æ¥ã®ããŒãºãå°é£ãåžžã«ç¥ã£ãŠããããã§ã¯ãããŸããã
圌ãã«ããªãã®æèŠãèãããŠãã ããã
䟿å©ãªãªã³ã¯
- CSS-TAG Houdiniãšãã£ã¿ãŒãã©ãã ãW3C
Houdiniãã©ããã®ææ°ãããªãã¯ããŒãžã§ã³ã - CSS-TAG Houdiniã¿ã¹ã¯ãã©ãŒã¹ä»æ§ ãGitHub
éçºããã»ã¹ãé²è¡äžã®å ¬åŒGitHubãªããžããªã - Houdiniãµã³ãã« ãGitHub
ã³ãŒãäŸã - Houdiniã¡ãŒãªã³ã°ãªã¹ã ãW3C
ããã§ã¯ãäžè¬çãªè³ªåãããããšãã§ããŸãã