UNPKG

scrawl-canvas

Version:
353 lines (313 loc) 12.5 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Demo DOM 003</title> <link href="css/normalize.css" rel="stylesheet" /> <link href="css/tests.css" rel="stylesheet" /> <style> #mystack { width: 500px; height: 500px; margin: 0 auto; } .red-text { color: red; background-color: lavender; } .circle { border-radius: 50%; background-color: pink; } </style> </head> <body> <h1><a href="index.html">Scrawl-canvas v8</a> - DOM test 003</h1> <h2>Dynamically create and clone Element artefacts; drag and drop elements around a Stack</h2> <h3>Drag and drop elements around the Stack</h3> <div id="mystack" data-scrawl-stack> <svg id="weathericon" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="128px" height="128px" viewbox="0 0 64 64"> <defs> <filter id="blur" width="200%" height="200%"> <feGaussianBlur in="SourceAlpha" stdDeviation="3"/> <feOffset dx="0" dy="4" result="offsetblur"/> <feComponentTransfer> <feFuncA type="linear" slope="0.05"/> </feComponentTransfer> <feMerge> <feMergeNode/> <feMergeNode in="SourceGraphic"/> </feMerge> </filter> <style type="text/css"><![CDATA[ /* ** CLOUDS */ @keyframes am-weather-cloud-2 { 0% { -webkit-transform: translate(0px,0px); -moz-transform: translate(0px,0px); -ms-transform: translate(0px,0px); transform: translate(0px,0px); } 50% { -webkit-transform: translate(2px,0px); -moz-transform: translate(2px,0px); -ms-transform: translate(2px,0px); transform: translate(2px,0px); } 100% { -webkit-transform: translate(0px,0px); -moz-transform: translate(0px,0px); -ms-transform: translate(0px,0px); transform: translate(0px,0px); } } .am-weather-cloud-2 { -webkit-animation-name: am-weather-cloud-2; -moz-animation-name: am-weather-cloud-2; animation-name: am-weather-cloud-2; -webkit-animation-duration: 3s; -moz-animation-duration: 3s; animation-duration: 3s; -webkit-animation-timing-function: linear; -moz-animation-timing-function: linear; animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; animation-iteration-count: infinite; } /* ** SUN */ @keyframes am-weather-sun { 0% { -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); } } .am-weather-sun { -webkit-animation-name: am-weather-sun; -moz-animation-name: am-weather-sun; -ms-animation-name: am-weather-sun; animation-name: am-weather-sun; -webkit-animation-duration: 9s; -moz-animation-duration: 9s; -ms-animation-duration: 9s; animation-duration: 9s; -webkit-animation-timing-function: linear; -moz-animation-timing-function: linear; -ms-animation-timing-function: linear; animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; -ms-animation-iteration-count: infinite; animation-iteration-count: infinite; } @keyframes am-weather-sun-shiny { 0% { stroke-dasharray: 3px 10px; stroke-dashoffset: 0px; } 50% { stroke-dasharray: 0.1px 10px; stroke-dashoffset: -1px; } 100% { stroke-dasharray: 3px 10px; stroke-dashoffset: 0px; } } .am-weather-sun-shiny line { -webkit-animation-name: am-weather-sun-shiny; -moz-animation-name: am-weather-sun-shiny; -ms-animation-name: am-weather-sun-shiny; animation-name: am-weather-sun-shiny; -webkit-animation-duration: 2s; -moz-animation-duration: 2s; -ms-animation-duration: 2s; animation-duration: 2s; -webkit-animation-timing-function: linear; -moz-animation-timing-function: linear; -ms-animation-timing-function: linear; animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; -ms-animation-iteration-count: infinite; animation-iteration-count: infinite; } /* ** SNOW */ @keyframes am-weather-snow { 0% { -webkit-transform: translateX(0) translateY(0); -moz-transform: translateX(0) translateY(0); -ms-transform: translateX(0) translateY(0); transform: translateX(0) translateY(0); } 33.33% { -webkit-transform: translateX(-1.2px) translateY(2px); -moz-transform: translateX(-1.2px) translateY(2px); -ms-transform: translateX(-1.2px) translateY(2px); transform: translateX(-1.2px) translateY(2px); } 66.66% { -webkit-transform: translateX(1.4px) translateY(4px); -moz-transform: translateX(1.4px) translateY(4px); -ms-transform: translateX(1.4px) translateY(4px); transform: translateX(1.4px) translateY(4px); opacity: 1; } 100% { -webkit-transform: translateX(-1.6px) translateY(6px); -moz-transform: translateX(-1.6px) translateY(6px); -ms-transform: translateX(-1.6px) translateY(6px); transform: translateX(-1.6px) translateY(6px); opacity: 0; } } .am-weather-snow-1 { -webkit-animation-name: am-weather-snow; -moz-animation-name: am-weather-snow; -ms-animation-name: am-weather-snow; animation-name: am-weather-snow; -webkit-animation-duration: 2s; -moz-animation-duration: 2s; -ms-animation-duration: 2s; animation-duration: 2s; -webkit-animation-timing-function: linear; -moz-animation-timing-function: linear; -ms-animation-timing-function: linear; animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; -ms-animation-iteration-count: infinite; animation-iteration-count: infinite; } .am-weather-snow-2 { -webkit-animation-name: am-weather-snow; -moz-animation-name: am-weather-snow; -ms-animation-name: am-weather-snow; animation-name: am-weather-snow; -webkit-animation-delay: 1.2s; -moz-animation-delay: 1.2s; -ms-animation-delay: 1.2s; animation-delay: 1.2s; -webkit-animation-duration: 2s; -moz-animation-duration: 2s; -ms-animation-duration: 2s; animation-duration: 2s; -webkit-animation-timing-function: linear; -moz-animation-timing-function: linear; -ms-animation-timing-function: linear; animation-timing-function: linear; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; -ms-animation-iteration-count: infinite; animation-iteration-count: infinite; } ]]></style> </defs> <g filter="url(#blur)" id="snowy-3"> <g transform="translate(20,10)"> <g transform="translate(0,16)"> <g class="am-weather-sun"> <g> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(45)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(90)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(135)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(180)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(225)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(270)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> <g transform="rotate(315)"> <line fill="none" stroke="orange" stroke-linecap="round" stroke-width="2" transform="translate(0,9)" x1="0" x2="0" y1="0" y2="3"/> </g> </g> <circle cx="0" cy="0" fill="orange" r="5" stroke="orange" stroke-width="2"/> </g> <g> <path d="M47.7,35.4c0-4.6-3.7-8.2-8.2-8.2c-1,0-1.9,0.2-2.8,0.5c-0.3-3.4-3.1-6.2-6.6-6.2c-3.7,0-6.7,3-6.7,6.7c0,0.8,0.2,1.6,0.4,2.3 c-0.3-0.1-0.7-0.1-1-0.1c-3.7,0-6.7,3-6.7,6.7c0,3.6,2.9,6.6,6.5,6.7l17.2,0C44.2,43.3,47.7,39.8,47.7,35.4z" fill="#57A0EE" stroke="white" stroke-linejoin="round" stroke-width="1.2" transform="translate(-20,-11)"/> </g> <g class="am-weather-snow-1"> <g transform="translate(7,28)"> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1.2" transform="translate(0,9), rotate(0)" x1="0" x2="0" y1="-2.5" y2="2.5" /> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1" transform="translate(0,9), rotate(45)" x1="0" x2="0" y1="-2.5" y2="2.5" /> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1" transform="translate(0,9), rotate(90)" x1="0" x2="0" y1="-2.5" y2="2.5" /> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1" transform="translate(0,9), rotate(135)" x1="0" x2="0" y1="-2.5" y2="2.5" /> </g> </g> <g class="am-weather-snow-2"> <g transform="translate(16,28)"> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1.2" transform="translate(0,9), rotate(0)" x1="0" x2="0" y1="-2.5" y2="2.5" /> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1" transform="translate(0,9), rotate(45)" x1="0" x2="0" y1="-2.5" y2="2.5" /> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1" transform="translate(0,9), rotate(90)" x1="0" x2="0" y1="-2.5" y2="2.5" /> <line fill="none" stroke="#57A0EE" stroke-linecap="round" stroke-width="1" transform="translate(0,9), rotate(135)" x1="0" x2="0" y1="-2.5" y2="2.5" /> </g> </g> </g> </g> </svg> <svg width="200px" height="150px" xmlns="http://www.w3.org/2000/svg" id="simple-svg" viewbox="0 0 400 300"> <rect width="100%" height="100%" fill="red" /> <circle cx="100%" cy="100%" r="150" fill="blue" stroke="black" /> <polygon points="120,0 240,225 0,225" fill="green"/> <text x="50" y="100" font-family="Verdana" font-size="55" fill="white" stroke="black" stroke-width="2">Hello!</text> </svg> </div> <p id="reportmessage"></p> <div class="testinfo"> <h4>Test purpose</h4> <ul> <li>Create, and clone, elements - adding them dynamically to the stack environment</li> <li>Check that elements can be created with CSS attributes</li> <li>Check that elements can be created with HTML class values</li> <li>Check that elements can be dragged and dropped around the stack environment, taking into account their current rotation values</li> </ul> <ul> <li>Import SVG elements into a Scrawl-canvas stack, by including the SVG 'inline' within the HTML markup</li> <li>Check that the SVG elements can be dragged and dropped, like other elements</li> </ul> <p><b>Known issue:</b> When Scrawl-canvas initializes, it checks for stack elements and attempts to replicate their CSS attributes. Reading the perspective attribute fails and leads to some interesting outcomes. Current workaround is to always set SC perspectiveZ value in Javascript code.</p> <p><b>Touch test:</b> should work as expected</p> <p><a href="../docs/demo/dom-003.html">Annotated code</a></p> </div> <script src="dom-003.js" type="module"></script> </body> </html>