Vanishing metamorphoses

I'm encountering a strange issue with phantomJS where it seems to be losing the transformations applied to certain images. On my webpage, I have a function that takes some HTML and inserts it into the page. Here's an example of how it looks:

function RenderRaw(html, id) {
    elem = $("#raw");
    elem.html(html);
}

The HTML I'm passing includes images with transformations like this:

<img id="map_layer0_tile_5_1_1" class="layerTile" style="width: 256px;
 height: 256px; visibility: visible; transform: translate(89px, -13px);" src="tile/5/11/5">

Everything works fine in my browser. However, when I check the image load event using debugDiv, I notice that the transform property is missing when running through phantomJS:

var imgs = elem.find("img");
imgs.on('load', function(e) {
    var off = $(e.target).offset();
    var p = $("<p>").text(e.target.outerHTML);
    debugDiv.append(p);
    debugDiv.append("<p>" + e.target.style.transform + "</p>");
    debugDiv.append("<p>" + e.target.style.width + ", " + e.target.style.height + "</p>");
    debugDiv.append("<p>" + e.target.src + ": top=" + off.top + ", left=" + off.left + "</p>");
}

While style.width and style.height can still be accessed as expected, the transform property appears to be stripped out.

After further investigation, it seems that phantomJS recognizes webkitTransform but not transform. Is there a workaround for this limitation?

Answer №1

It appears that the issue lies with phantomJS 2.0 lacking support for the transform property altogether. This information was not provided in the version's release notes, unfortunately. To address this issue, I implemented the following solution within the load event for each image:

var currentImage = $(event.target);
if (event.target.style.transform === undefined && event.target.style.webkitTransform !== undefined) {
    var styleAttribute = currentImage.attr("style");
    styleAttribute += "-webkit-transform: " + /transform:([^;]*;)/.exec(styleAttribute)[1];
    currentImage.attr("style", styleAttribute);
}

This essentially involves extracting the transform property and duplicating it as the -webkit-transform.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is the CSS selector '.my-class *:not(input[type="text"])' accurate?

Is there a way to target all elements inside the DOM element with class "my-class" except for input elements of type text? I tried using the following CSS selector: .my-class *:not(input[type="text"]) { // Some CSS properties here } However, this do ...

Ajax Complete adds Jquery two times in a row

I have a simple ajax complete call that is designed to add some text after an ajax load finishes. However, I'm encountering an issue where the information is sometimes displayed multiple times. I suspect there might be something missing in my approach ...

Using ng-init to pass a JSON object

I'm attempting to pass a JSON Object to my application using ng-init and the stringify method, but I am encountering an error. Instead of working as expected, I am getting a Lexer error. Lexer Error: Unexpected next character at columns 8-8 [#] in ex ...

Checking sessions on cross-domain requests made with $.ajax()

There is a jQuery $.ajax code on domain A and a domain B, which is a PHP server. Step 1: The user is already logged in on the PHP server [B]. Step 2: The user visits domain A and sends an Ajax request (containing only an empty string) to the PHP server. ...

Refresh PHP Calculator Display Once Results are Shown

Currently working on a basic calculator project coded in HTML, CSS, JS, and PHP. Here is a glimpse of it: The user input retrieval is handled by JS, while the actual calculations and result display are taken care of by PHP. I am striving to clear out the ...

JQuery - stylish vertical accordion navigation menu

I'm currently working on a vertical accordion-style sidebar navigation system. Everything seems to be functioning properly, but I've encountered some issues with the icons that I'm using from Twitter Bootstrap 3. You can view the code on th ...

Collision of CSS styles with a different CSS stylesheet causing conflicts

Currently, I am in the process of developing a website and have encountered a specific issue. Within my page, there are various divs and tables present. I have meticulously crafted classes and styles to customize the appearance of these elements to align ...

What is the process for including a field specific to a date in a form?

I need the user to select a month and year. In one column, there will be the days of the month they selected [e.g. 1-30]. Users can then add habits in other columns. I want users to be able to input an 'X' for each habit row on a specific date [e ...

Displaying and hiding elements as the page is scrolled

Is there a way to create a single scrolling page with a fixed element that remains visible as the user scrolls down? Imagine an image of a car on a road, where the car appears to be moving down the road as the user scrolls. The car should go under certain ...

Having issues with the onclick _dopostback function in MVC? It seems like the post

When attempting to execute a postback in ASP.NET MVC after confirming with JavaScript, the following button is used: <input type="submit" id ="RemoveStatus" value="Remove Status" name="button" onclick="return CheckRemove();"/> The JavaScript code f ...

The functionality of display flex is not functioning as expected outside of the CodePen

I attempted to create a responsive two-column layout on Codepen with success. The layout is quite simple, featuring a YouTube video and some text. However, when I tried to transfer this to my website, it failed to work... Here is the code – hoping someo ...

Create a PHP form that includes text and image inputs with the help of AdminLTE and integrates DropZone.js

I have been working with a template from adminLTE and you can check it out at the following link: . At this point, I am trying to upload images first and then use the image names as input text elements in my main form for submission. However, I have encou ...

Is there a way to incorporate multer middleware into my express controller without using the router?

This is the structure I typically follow when writing controllers and routes using Express controller exports.postBlog = async (req, res, next) => {...} routes router.route("/post").post(onlyAdmin, postBlog); *onlyAdmin serves as a middlewa ...

The criteria is not fulfilled by either item.area_partition.homepage_show or item.area_partition.name in accordance with my needs

I am having an issue with some code snippet: <Col span="8" v-for="(item,index) in this.data" > <Card> <p slot="title" style="">{{ item.area_partition.homepage_show || item.area_partition. ...

How do I access the content of a webpage once it has been generated using a template engine?

Currently, I am engaging in screen scraping for a website that heavily relies on JavaScript. The site utilizes a client-side templating engine to display all of its content. Initially, I attempted to use jQuery, which proved successful in the console but n ...

"An alternative approach in node.js for implementing an AJAX saving mechanism, similar to the

For my JavaScript (client) + PHP (server) website, I have a system in place to save an "online notepad" from a #textbox textarea to the server: // client-side $("#save-button").on('click', save); function save(e) { $.ajax({ type: "POST", ...

Exploring the efficiency of different CSS selectors

I am struggling with the following code: HTML: <ul class="list"> <li class="list-item"> item 1 </li> <li class="list-item list-item_active"> Active item </li> <li class="list-item"> item 3 </li> ...

PHP Script unable to locate results

For some reason, the script I have written is not functioning properly. Upon reviewing the code from walmart.com, I verified that name="query" is accurate. However, I am uncertain about the contents within <script></script> <html> < ...

The property 'dateClick' is not found in the 'CalendarOptions' type in version 6 of fullcalendar

Below is the Angular code snippet I am currently using: calendarOptions: CalendarOptions = { plugins: [ dayGridPlugin, timeGridPlugin, listPlugin ], initialView: 'dayGridMonth', headerToolbar: { left: 'prev today next' ...

Having a bottom border only on input fields appears strange when viewed on a mobile device

When trying to achieve a bottom border on mobile, I encountered an unexpected issue where a strange line appeared instead in the browser. Here is an image of the problem: https://i.sstatic.net/PqEOF.jpg I expected to see a straight line as intended (it w ...