Polymer - the content tag within core-animated-pages does not properly adjust its height

My goal is to give each element on my list 2 pages or views, with generic content (<content></content>) for each. However, I'm running into an issue where the elements are overlapping when using core-animated-pages to wrap the generic content. It seems that this is due to the animated-pages converting the content position to absolute, which I don't want to change. But why isn't the element content taking its child height into account in this scenario?

To demonstrate what I'm trying to achieve, I took the demo from the Polymer site and customized it a bit. In the post-card.html file, I added the core-animated-pages so that clicking on each element switches the view to "NEXT PAGE!".


    <core-animated-pages id="p" on-tap="{{togglePage}}" transitions="cross-fade-all">
    <section>
    <div class="card-header" layout horizontal center>

      <content select="img"></content>
      <content select="h2"></content>

    </div>

    <core-icon-button
      id="favicon"
      icon="favorite"
      on-tap="{{favoriteTapped}}">
    </core-icon-button>

    <content></content>
    </section>
    <section>
      <p>NEXT PAGE!</p>
    </section>
    </core-animated-pages>
    </template> 
  <script>
   Polymer ({
    publish: {
      favorite: {
        value: false,
        reflect: true
      }
    },
    favoriteTapped: function(event, detail, sender) {
      this.favorite = !this.favorite;
      this.fire('favorite-tap');
    },
    togglePage: function () {
      var max = 1;
      if (this.$.p.selected === max) {
        this.$.p.selected -= 1;
      } else {
        this.$.p.selected += 1;
      }
    }
  });
  </script>

Answer №1

Utilizing data-binding is a great way to manage the selected attribute within the core-animated-pages tag.

<core-animated-pages 
    id="p" 
    on-tap="{{togglePage}}" 
    transitions="cross-fade-all"
    selected="{{mySelected}}"
>

<script>
Polymer({
    mySelected: 0, //default value
    togglePage: function(){
        var max = 1;
        if (this.$.p.selected === max) {
            this.mySelected -= 1;
        } else {
            this.mySelected += 1;
        }
    }
})

If this method does not yield results, consider moving the on-tap attribute to the section tag.

<section on-tap="{{togglePage}}"></section>

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

The troubleshooting of a find method in Mongoose

Why is it necessary to use await twice when calling the model function, even though we already used await in the model itself: async function model() { return await data.find({}, '-_id -__v') } When I console.log await data.find({}, '-_id ...

Notification that variables will output either "length" or "item"

I have a 16x16 table and I am assigning a lambda function to all the td elements like this: function handlerAssignment() { var trs = document.getElementsByTagName("tr"); var tds; for (var i=0; i<trs.length; i++) { tds = trs[i].getE ...

JavaScript code for transitioning between a thumbnail and a full-width image header on a webpage

I am looking to create transitions in NextJs that involve a smooth shift from a thumbnail image to a full-screen header when clicking on a project from the home page. I prefer utilizing internal routing rather than React Router, but I am open to using that ...

How can you refresh a webpage with Javascript only one time?

When I use the resize function to reload my page, I only want it to reload once when the page size changes from small (less than or equal to 768px) to big or vice versa. Here is my current code: $(window).resize(function(){ // if(document.body.clientWid ...

Press a Selenium button that is not categorized as an input element

I have the following HTML snippet: <div _ngcontent-fsi-c26="" class="col-xs-12 ng-star-inserted" style="margin-top: 3%;"> <div _ngcontent-fsi-c26="" class=" col-xs-offset-1 c ...

Tips for effectively utilizing Enums with switch statements in typescript

In one file, I have the following code snippet: export module Utils { export enum DataSources { SharepointList = "SharepointList", JsonData = "JsonData" }; } And in another file, there is the following code: import CustomerDAO f ...

A Guide to Organizing Vue Js: Dividing 'methods', 'data', 'computed', and More into Separate JavaScript Files

Is it feasible to separate methods, data, computed properties, etc. into individual .js files and then import them into a component.vue file? I prefer not to include all JavaScript logic in a single .vue component. My ideal code organization for each com ...

Transcluding an element into an ng-repeat template in AngularJS: How can it be done?

Incorporating a carousel directive involves chunking the passed in array of items and mapping it into an array of arrays of elements. This structure then generates markup resembling the pseudo code provided below: <array of arrays> <array of i ...

Should we pass <script> tags or unsanitized values to the Handlebars layout?

How can I pass values to handlebars that are not sanitized upon output? For instance, I want to ensure that when using the code res.render('index', {script: '<script src="bundle.js"></script>'}), it is not rendered as {{scri ...

Discovering the destination URL that an HTML button submits to

While attempting to scrape data from instacart.com, I encountered the requirement of entering a zip code to determine the displayed information. My intention is to utilize Python requests to submit a random zip code. However, I am unsure of which URL to po ...

Stop the execution of the JavaScript function when clicked

Greetings, as a newcomer to the realm of JavaScript and AJAX, I am seeking assistance with a specific function on this page. The concept revolves around triggering different JavaScript functions based on user interaction with an image map. Initially, when ...

How to turn off a sticky header on Mobile using CSS

Below is the code I am using to create a fixed header on my website. <?php } ?> <header id="header" class="<?php if ( theme_option( THEME_OPTIONS, 'enable_header_fixed' ) == 'true' ) : ?> fixed_header <?php else : ?&g ...

How to populate the space beneath the `AreaChart` curve in `recharts` when data includes positive and negative values

How can I modify my chart, created using the recharts library in JavaScript, so that the area under the curve fills to the bottom of the visible area instead of stopping at zero? This is how it currently looks: https://i.sstatic.net/CCHXu.png My goal is ...

Issue with Aligning Layout in Angular Material Design

It seems like my Angular Material code is not aligning my divs properly. Could this be due to the latest version of Angular Material? The previous version (0.8.3) worked fine with the same code. Do I need to make any additional changes for the current vers ...

Update the image source through an AJAX call

I've experimented with various methods to update an image src using an AJAX request. The new URL is obtained through the AJAX call, and when inspecting the data in Developer Tools, the 'DATA' variable contains the correct URL. However, the i ...

Getting a file object with v-file-input in Nuxt.js

For my Nuxt.Js apps, I utilized Vuetify.js as the UI framework. In order to obtain the file object when uploading files, I incorporated the v-file-input component from Vuetify.js and wrote the following code snippet: <template> <div> ...

Load Vue 3 components dynamically using a string-based approach

Exploring ways to dynamically load components based on a string input. Here is an attempt at achieving this: <component v-for="component in components" :is="eval(component)" /> However, this approach does not yield the desired r ...

Issues with Vue enter transitions not functioning as expected

I am currently involved in a project where I need to implement enter and exit animations for some components. When a component enters the screen, it should come from the bottom, and when it leaves, it should go upwards. The intended functionality is that w ...

Associating Values with an HTML Table

Below is the code for an HTML table containing text boxes and dropdown lists. The goal is to bind values from a dataset to the HTML table, but it is only binding one row out of 15 records. I need assistance in resolving this issue. ASP.NET Code :- publi ...

I'm encountering an error in my routes index.js file that says "Module not found"

The issue is stating "Cannot find module './routes/index'" despite it being located in that directory (even when static is set to that folder) Here is the error: root@ip*censored*:/home/ubuntu/*censored*# module.js:471 throw err; ^ Err ...