{"id":38505,"date":"2018-05-31T03:01:09","date_gmt":"2018-05-30T17:01:09","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=38505"},"modified":"2018-05-31T07:12:50","modified_gmt":"2018-05-30T21:12:50","slug":"html-table-cell-maintained-dimensions-variably-zoomed-content-transform-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-table-cell-maintained-dimensions-variably-zoomed-content-transform-tutorial\/","title":{"rendered":"HTML Table Cell Maintained Dimensions Variably Zoomed Content Transform Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"HTML Table Cell Maintained Dimensions Variably Zoomed Content Transform Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle_transform.jpg\" title=\"HTML Table Cell Maintained Dimensions Variably Zoomed Content Transform Tutorial\"   \/><\/a><p class=\"wp-caption-text\">HTML Table Cell Maintained Dimensions Variably Zoomed Content Transform Tutorial<\/p><\/div>\n<p>In yesterday&#8217;s <a title='HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial' href='#htmltcmdvzcpt'>HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial<\/a> you eagled-eyed readers will have noted a means by which we &#8230;<\/p>\n<ol>\n<li>made life easier for ourselves &#8230; and &#8230;<\/li>\n<li>aided with genericization<\/li>\n<\/ol>\n<p> &#8230; going from the static Zoom=50% (Scale=0.5) display scenarios of <a target=_blank title='Speech to Text LibreOffice Template Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/speech-to-text-libreoffice-template-tutorial\/'>Speech to Text LibreOffice Template Tutorial<\/a> to the user controlled dynamic HTML iframe &#8220;child&#8221; ways of yesterday was to involve a CSS <b>Property<\/b> called &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='CSS transform-origin Property information from W3schools' href='https:\/\/www.w3schools.com\/cssref\/css3_pr_transform-origin.asp'>transform-origin<\/a><br \/>\n... as in the CSS definition ...<br \/>\n&lt;style&gt;<br \/>\n#myDIV {<br \/>\n    transform-origin: 20% 40%;<br \/>\n}<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; which can also be expressed (in a more dynamic way, at least in our books <font size=1>&#8230; but never in our pamphlettes &#8230;<\/font>) via Javascript DOM <b>style<\/b> &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Style transformOrigin Property information from W3schools' href='https:\/\/www.w3schools.com\/jsref\/prop_style_transformorigin.asp'>[HTMLElementObject].style.transformOrigin<\/a><br \/>\n... as in the Javascript (DOM) (equivalent) codeline (to CSS example above) ...<br \/>\ndocument.getElementById(\"myDIV\").style.transformOrigin = \"20% 40%\";<br \/>\n<\/code><\/p>\n<p> &#8230; except that yesterday, in order not to do our head in, we had a CSS transform-origin or Javascript DOM [HTMLElementObject].style.transformOrigin scenario of <b>0% 0%<\/b> &#8230; in other words, <b>&#8220;scale from the top left&#8221;<\/b> (or maybe you&#8217;d prefer the habit of <i>left top<\/i> to keep x, y as preferred <i>thinking<\/i> order).<\/p>\n<p>Why even talk about this?  Well, the default CSS transform-origin or Javascript DOM [HTMLElementObject].style.transformOrigin scenario is, in &#8220;HTML web browser land&#8221;, <b>50% 50%<\/b> which is a mathematical approach sensible default in our books (<font size=1>pamphlettes? smamplettes?!<\/font>), but not of practical benefit to the idea of squeezing zoomed content into tight spaces.  Sorry not to go fully &#8220;International&#8221; in my thinking, but we left to right readers tend to look at the <strike>top left<\/strike> left top as our eye focus point, so it makes more sense for we left to right readers to use CSS transform-origin or Javascript DOM [HTMLElementObject].style.transformOrigin scenario of <b>0% 0%<\/b> as the &#8220;hinge point&#8221; for <i>transformations<\/i>.   Now, there&#8217;s the word we wanted to get to &#8230; <i>transformations<\/i> &#8230; in &#8220;CSS land&#8221; (and hence &#8220;Javascript DOM land&#8221; too) a wide variety of functionality for <i>transformation<\/i> (of HTML elements) exists.  The ones we make user controllable today go like the CSS 2D <b>Property<\/b> &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='CSS transform Property information from W3schools' href='https:\/\/www.w3schools.com\/cssref\/css3_pr_transform.asp'>transform<\/a><br \/>\n... as in the CSS definition ...<br \/>\n&lt;style&gt;<br \/>\n#myDIV {<br \/>\n    transform: scale(0.5) rotate(0deg) translate(0%,0%) skew(0deg,0deg);<br \/>\n}<br \/>\n&lt;\/style&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; <font size=2>and yes, there are 3D ones too<\/font> &#8230; which can also be expressed (in a more &#8220;way dynam<font size=1>agnifencent<\/font>ique&#8221;, at least in our books <font size=1>&#8230; reject these paplettes &#8230;<\/font>) via Javascript DOM <b>style<\/b> &#8230;<\/p>\n<p><code><br \/>\n<a target=_blank title='Style transform Property information from W3schools' href='https:\/\/www.w3schools.com\/jsref\/prop_style_transform.asp'>[HTMLElementObject].style.transform<\/a><br \/>\n... as in the Javascript (DOM) (equivalent) codeline (to CSS example above) ...<br \/>\ndocument.getElementById(\"myDIV\").style.transform = \"scale(0.5) rotate(0deg) translate(0%,0%) skew(0deg,0deg)\";<br \/>\n<\/code><\/p>\n<p> &#8230; and so, it&#8217;s our job, in our new Javascript function &#8230;<\/p>\n<p><code><br \/>\nfunction tochange(cthis) {<br \/>\n  var skewsuffix=\" skew(\" + document.getElementById('skewleft').value + \"deg,\" + document.getElementById('skewtop').value + \"deg)\";<br \/>\n  var tlsuffix=\" translate(\" + document.getElementById('translateleft').value + document.getElementById('translateleftb').value + \",\" + document.getElementById('translatetop').value + document.getElementById('translatetopb').value + \")\";<br \/>\n  if (cthis.id.indexOf('rotation') != -1) {  \/\/ rotation change<br \/>\n    var retval=\" rotate(\" + cthis.value + \"deg)\" + skewsuffix + tlsuffix;<br \/>\n    document.getElementById(prefx + 'ihangman').style.transform=\"scale(\" + document.getElementById('scale').value + \")\" + retval;<br \/>\n    return retval;<br \/>\n  } else if (cthis.id.indexOf('translate') != -1) {  \/\/ translation change<br \/>\n    document.getElementById(prefx + 'ihangman').style.transform=\"scale(\" + document.getElementById('scale').value + \")\" + \" rotate(\" + document.getElementById('rotation').value + \"deg)\" + skewsuffix + tlsuffix;<br \/>\n    return tlsuffix;<br \/>\n  } else if (cthis.id.indexOf('skew') != -1) {  \/\/ translation change<br \/>\n    document.getElementById(prefx + 'ihangman').style.transform=\"scale(\" + document.getElementById('scale').value + \")\" + \" rotate(\" + document.getElementById('rotation').value + \"deg)\" + skewsuffix + tlsuffix;<br \/>\n    return skewsuffix;<br \/>\n  } else if (cthis.id.indexOf('b') != -1) {  \/\/ unit change<br \/>\n    if (cthis.id.indexOf('left') != -1) {  \/\/ x (left) change<br \/>\n     document.getElementById(prefx + 'ihangman').style.transformOrigin=\"\" + document.getElementById(cthis.id.replace('b','')).value + document.getElementById(cthis.id.replace('b','') + 'b').value + \" \" + document.getElementById('totop').value + document.getElementById('totopb').value;<br \/>\n    } else {  \/\/ y (top) change<br \/>\n     document.getElementById(prefx + 'ihangman').style.transformOrigin=\"\" + document.getElementById('toleft').value + document.getElementById('toleftb').value + \" \" +  + document.getElementById(cthis.id.replace('b','')).value + document.getElementById(cthis.id.replace('b','') + 'b').value;<br \/>\n    }<br \/>\n  } else {  \/\/ value change<br \/>\n    if (cthis.id.indexOf('left') != -1) {  \/\/ x (left) change<br \/>\n     document.getElementById(prefx + 'ihangman').style.transformOrigin=\"\" + document.getElementById(cthis.id.replace('b','')).value + document.getElementById(cthis.id.replace('b','') + 'b').value + \" \" + document.getElementById('totop').value + document.getElementById('totopb').value;<br \/>\n    } else {  \/\/ y (top) change<br \/>\n     document.getElementById(prefx + 'ihangman').style.transformOrigin=\"\" + document.getElementById('toleft').value + document.getElementById('toleftb').value + \" \" +  + document.getElementById(cthis.id.replace('b','')).value + document.getElementById(cthis.id.replace('b','') + 'b').value;<br \/>\n    }<br \/>\n  }<br \/>\n  return \"\";<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; to piece all that new user controlled HTML element data into a Javascript DOM statement like above, in order to make the resultant HTML table cell (with maintained dimensions) zoomed or scaled (or not) content be more manipulative (<font size=1>that dastardly content?!<\/font>).<\/p>\n<p>Again, try a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html\">live run<\/a> link into a new window or see it in an HTML iframe below &#8230;<\/p>\n<p><iframe style='height:100vh;width:100%;' src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html'><\/iframe><\/p>\n<p> &#8230; and HTML and Javascript and CSS <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html--GETME\">zoom_in_middle.html<\/a> code (that changed <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html--GETME\">>this way<\/a>) you can download if you like.  Again, we hope it is food for thought for you.<\/p>\n<hr>\n<p id='htmltcmdvzcpt'>Previous relevant <a target=_blank title='HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/html-table-cell-maintained-dimensions-variably-zoomed-content-primer-tutorial\/'>HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.jpg\" title=\"HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a target=_blank title='Speech to Text LibreOffice Template Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/speech-to-text-libreoffice-template-tutorial\/'>Speech to Text LibreOffice Template Tutorial<\/a> had synergies with process, explained yesterday, and synergies with trying to express zoomed content in a limited space, involving two quite different concepts &#8230;<\/p>\n<ul>\n<li>Hangman Game<\/li>\n<li>LibreOffice Template<\/li>\n<\/ul>\n<p> &#8230; us deciding on a static Zoom=50% (Scale=0.5) display with this in yesterday&#8217;s work.  This got us wondering if we can design a proof of concept web application where &#8230;<\/p>\n<ul>\n<li>the Zooming (or Scaling) can be dynamically selected by the user, bit like those magnifier functionalities so popular on fashion eCommerce websites<\/li>\n<li>a couple of content choices (as above) can be dynamically selected by the user<\/li>\n<li>the display of this content can be created at &#8230;\n<ol>\n<li>document.body onload event &#8230; and\/or &#8230;<\/li>\n<li>onclick event &#8230; shared Javascript code as per &#8230;<br \/>\n<code><br \/>\nfunction load_zoomed_content(prefix,othis) {<br \/>\n    prefx=prefix;<br \/>\n    if (othis.innerHTML.indexOf('over' + 'flow') == -1) othis.innerHTML+='&lt;div onclick=\"prefx=' + \"'\" + prefix + \"';\" + '\" id=\"' + prefix + 'divhangman\" style=\"background-color:white;overflow:hidden;width:100%;height:100%;\"&gt;&lt;\/div&gt;';<br \/>\n    myw=eval(window.getComputedStyle(document.getElementById(prefix + 'divhangman'), null).getPropertyValue('width').replace('px','')); \/\/ + myw;<br \/>\n    myh=eval(window.getComputedStyle(document.getElementById(prefix + 'divhangman'), null).getPropertyValue('height').replace('px','')); \/\/ + myh;<br \/>\n    document.getElementById(prefix + 'divhangman').innerHTML='&lt;iframe onclick=\"prefx=' + \"'\" + prefix + \"';\" + '\" style=\"border:1px solid red;transform-origin: 0% 0%;transform:scale(' + document.getElementById('scale').value + '); -o-transform: scale(' + document.getElementById('scale').value + '); -moz-transform: scale(' + document.getElementById('scale').value + '); -ms-transform: scale(' + document.getElementById('scale').value + '); -webkit-transform:  scale(' + document.getElementById('scale').value + ');width:' + Math.floor(eval(eval(100.0 \/ document.getElementById('scale').value))) + '%;height:' + Math.floor(eval(eval(100.0 \/ document.getElementById('scale').value))) + '%;\" id=\"' + prefix + 'ihangman\" src=\"hangman_bg.html?curplayer=' + curplayer + '&tosolve=' + encodeURIComponent(swhatshort) + \"&clue=\" + encodeURIComponent(clue) + '\"&gt;&lt;\/iframe&gt;';<br \/>\n    if (document.getElementById('ohangman').value.indexOf('?') == -1) {<br \/>\n     prefx=prefix;<br \/>\n     docontent('hangman_bg.html?curplayer=' + curplayer + '&tosolve=' + encodeURIComponent(swhatshort) + \"&clue=\" + encodeURIComponent(clue));<br \/>\n     doscale(document.getElementById('scale').value);<br \/>\n    } else {<br \/>\n     prefx=prefix;<br \/>\n     docontent(document.getElementById('content').value);<br \/>\n     doscale(document.getElementById('scale').value);<br \/>\n    }<br \/>\n    othis.style.width=Math.floor(eval(myw)) + 'px';<br \/>\n    othis.style.height=Math.floor(eval(myh)) + 'px';<br \/>\n    othis.style.maxWidth=Math.floor(eval(myw)) + 'px';<br \/>\n    othis.style.maxHeight=Math.floor(eval(myh)) + 'px';<br \/>\n    document.getElementById(prefix + 'divhangman').style.width=Math.floor(eval(myw)) + 'px';<br \/>\n    document.getElementById(prefix + 'divhangman').style.height=Math.floor(eval(myh)) + 'px';<br \/>\n    document.getElementById(prefix + 'divhangman').style.maxWidth=Math.floor(eval(myw)) + 'px';<br \/>\n    document.getElementById(prefix + 'divhangman').style.maxHeight=Math.floor(eval(myh)) + 'px';<br \/>\n    document.getElementById(prefix + 'ihangman').style.width=Math.floor(eval(eval(1.0 \/ document.getElementById('scale').value) * myw)) + 'px';<br \/>\n    document.getElementById(prefix + 'ihangman').style.height=Math.floor(eval(eval(1.0 \/ document.getElementById('scale').value) * myh)) + 'px';<br \/>\n    document.getElementById(prefix + 'ihangman').style.maxWidth=Math.floor(eval(eval(1.0 \/ document.getElementById('scale').value) * myw)) + 'px';<br \/>\n    document.getElementById(prefix + 'ihangman').style.maxHeight=Math.floor(eval(eval(1.0 \/ document.getElementById('scale').value) * myh)) + 'px';<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<\/ol>\n<\/li>\n<li>for a webpage consisting of a 3&#215;3 grid of HTML table cells (td)<\/li>\n<\/ul>\n<p>Try a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html\">live run<\/a> link into a new window or see it in an HTML iframe below &#8230;<\/p>\n<p><iframe style='height:100vh;width:100%;' src='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html'><\/iframe><\/p>\n<p> &#8230; and HTML and Javascript and CSS <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/zoom_in_middle.html-GETME\">zoom_in_middle.html<\/a> code you can download if you like.  We hope it is food for thought for you.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d38487' onclick='var dv=document.getElementById(\"d38487\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/scale\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d38487' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d38505' onclick='var dv=document.getElementById(\"d38505\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/skew\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d38505' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In yesterday&#8217;s HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial you eagled-eyed readers will have noted a means by which we &#8230; made life easier for ourselves &#8230; and &#8230; aided with genericization &#8230; going from the static &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html-table-cell-maintained-dimensions-variably-zoomed-content-transform-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[1580,281,342,576,587,652,2562,2563,2561,997,1071,1094,1147,1238,1581,1298,1300,1319,1498],"class_list":["post-38505","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-cell","tag-css","tag-div","tag-html","tag-iframe","tag-javascript","tag-magnifier","tag-origin","tag-overflow","tag-programming","tag-rotate","tag-scale","tag-skew","tag-table","tag-table-cell","tag-transform","tag-translate","tag-tutorial","tag-zoom"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/38505"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=38505"}],"version-history":[{"count":4,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/38505\/revisions"}],"predecessor-version":[{"id":38521,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/38505\/revisions\/38521"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=38505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=38505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=38505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}