{"id":67,"date":"2013-04-26T01:04:00","date_gmt":"2013-04-26T01:04:00","guid":{"rendered":"http:\/\/reichartonline.de\/?page_id=67"},"modified":"2020-05-10T08:20:56","modified_gmt":"2020-05-10T08:20:56","slug":"floating-zoomers","status":"publish","type":"page","link":"https:\/\/reichartonline.de\/?page_id=67","title":{"rendered":"Floating Zoomers"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>Have you ever wondered how difficult it is to implement from scratch animated floating pop-ups containing whatever web page one may want?<\/p>\n<div id=\"attachment_96\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2013\/04\/floating_zoomer.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-96\" class=\"wp-image-96 size-medium\" src=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2013\/04\/floating_zoomer-300x167.png\" alt=\"Floating Zoomer\" width=\"300\" height=\"167\" srcset=\"https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2013\/04\/floating_zoomer-300x167.png 300w, https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2013\/04\/floating_zoomer.png 581w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-96\" class=\"wp-caption-text\">Floating Zoomer<\/p><\/div>\n<p>Note that these are not HTML tooltips as those are limited in terms of customization (may not contain links, images etc.). So one could use a considerable amount of Javascript code to work around these limitations or&#8230;<\/p>\n<p><strong>The HTML part<\/strong><\/p>\n<p>This approach is based on a generic and empty HTML object that we hiddenly load as part of our web page. Therefore a single line of HTML code is required.<\/p>\n<p>HTML<\/p>\n<pre lang=\"HTML\">&lt;object name=\"zoom_object\" id=\"zoom_object\"\n       type=\"text\/html\"\n       onmouseout=\"javascript:FadeOutZoom();\"&gt;\n&lt;\/object&gt;<\/pre>\n<p>This is not even HTML 5, so no modern browser should have an issue with it.<\/p>\n<p><strong>The CSS part<\/strong><\/p>\n<p>The size of the object is defined within the corresponding CSS class. To make it float above &#8220;ground level&#8221;, a layer index greater than 1 (20 for this example) is set.<\/p>\n<p>CSS<\/p>\n<pre lang=\"CSS\">object.float\n{\n  z-index: 20;\n  position: absolute;\n  width: 450px;\n  height: 200px;\n  border-top: 2px solid silver;\n  border-bottom: 2px solid silver;\n  border-left: 2px solid silver;\n  border-top-left-radius: 10px;\n  border-top-right-radius: 10px;\n  border-bottom-left-radius: 10px;\n  border-bottom-right-radius: 10px;\n  box-shadow: 10px 10px 5px #888;\n  visibility: hidden;\n  opacity: 0;\n  transition: visibility 0.5s linear, opacity 0.5s linear;\n}<\/pre>\n<p>The &#8220;radius&#8221;, &#8220;opacity&#8221; and &#8220;transition&#8221; attributes have been introduced with CSS version 3 which is why legacy browsers may not yet support them. But this is only style, the basic feature will work.<\/p>\n<p><strong>The Javascript part<\/strong><\/p>\n<p>Now some Javascript code is required to<\/p>\n<ul>\n<li>position the floating element at the mouse pointer when the same hovers the underlying HTML element (no CSS &#8220;.hover&#8221; sub class used as the hovered element is not the same as the one that appears and it&#8217;s not an HTML tooltip)<\/li>\n<li>change style attributes of the floating element to make it visible and to fade in (opacity)<\/li>\n<li>load content into floating element<\/li>\n<li>reset style attributes of the floating element when mouse leaves the same<\/li>\n<\/ul>\n<p>Javascript<\/p>\n<pre lang=\"Javascript\">var objZoom = document.getElementById( \"zoom_object\" );\nvar intPosX = 0;\nvar intPosY = 0;\n\n\/\/ Map event handler to function\ndocument.onmousemove = HandleMouseMove;\n\n\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\nfunction HandleMouseMove( jsEvent )\n{\n\tif ( !jsEvent )\n\t{\n\t\tvar jsEvent = window.event;\n\t}\n\n\t\/\/ The different methods address different browsers\n\tif ( jsEvent.pageX || jsEvent.pageY )\n\t{\n\t\tintPosX = jsEvent.pageX;\n\t\tintPosY = jsEvent.pageY;\n\t}\n\telse if ( jsEvent.clientX || jsEvent.clientY )\n\t{\n\t\tintPosX = jsEvent.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;\n\t\tintPosY = jsEvent.clientY + document.body.scrollTop + document.documentElement.scrollTop;\n\t}\n}\n\n\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\nfunction FadeInZoom( strURI )\n{\n\t\/\/ Cache content until update is requested\n\tif ( objZoom.getAttribute( 'data') != strURI )\n\t{\n\t\tUpdateZoomObject( strURI );\t\t\n\t}\n\n\tobjZoom.style.left = intPosX + \"px\";\n\tobjZoom.style.top = ( intPosY - objZoom.offsetHeight ) + \"px\";\n\tobjZoom.style.visibility = \"visible\";\n\tobjZoom.style.opacity = \"0.9\";\n\tobjZoom.style.transitionDelay = \"0.5s\";\n}\n\n\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\nfunction FadeOutZoom()\n{\n\tobjZoom.style.visibility = \"hidden\";\n\tobjZoom.style.opacity = \"0\";\n\tobjZoom.style.transitionDelay = \"0.2s\";\n}\n\n\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\nfunction UpdateZoomObject( strURI )\n{\n\tobjZoom.setAttribute( 'data', strURI );\n}<\/pre>\n<p><strong>Summary<\/strong><\/p>\n<p>This is all the code needed to generically load any web page (including images, links, tables etc.) into a floating HTML object that may be bound to any HTML element on the web page, while the floating element is fully styleable and customizable with regards to transition timing using CSS.<\/p>\n<p>Note: For the binding to take place dynamically, some additional code in your preferred back-end language is required.<\/p>\n<p>You can test the result in the <a href=\"https:\/\/www.reichartonline.de\/inftec\/housekeeping\/login.php\" target=\"_blank\" rel=\"noopener noreferrer\">Housekeeping demo instance<\/a> hovering a zoomable element (marked with a magnifying glass).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Have you ever wondered how difficult it is to implement from scratch animated floating pop-ups containing whatever web page one may want? Note that these are not HTML tooltips as those are limited in terms of customization (may not contain links, images etc.). So one could use a considerable amount of Javascript code to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":62,"menu_order":5,"comment_status":"open","ping_status":"open","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-67","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67"}],"version-history":[{"count":17,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/67\/revisions"}],"predecessor-version":[{"id":1126,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/67\/revisions\/1126"}],"up":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/62"}],"wp:attachment":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}