Giter Site home page Giter Site logo

ngx-gist's People

Contributors

dependabot[bot] avatar ekkolon avatar

Stargazers

 avatar

Watchers

 avatar

ngx-gist's Issues

[Bug] Iframe not rendered correctly when displaying different files from a gist in seperate ngx-gist components

Describe the bug
When trying to render a gist containing multiple files in seperate ngx-gist components,
the iframes are just partially rendered.

For example:

// example-page.component.ts

@Component({
 templateUrl: './example-page.component.html'
})
export class ExamplePage {
 gistId = "05151ac90b51a5d3a0c3e85cb942a456"
}
// example-page.component.html

<div class="ngx-gist-embed-single-file">
 <ngx-gist [gistId]="gistId" file="ngx_gist_embed_example_2.py"></ngx-gist>
</div>

<div class="ngx-gist-embed-all-files">
 <ngx-gist [gistId]="gistId"></ngx-gist>
</div>

Expected behavior
Expected both iframes to render the whole content while automatically adjusting the iframe's height.

Screenshots

ngx-gist-iframe-rendering-error

Traceback

This layout error may be caused by using the same iframe id for both ngx-gist components
when the component computes property bindings:

/**
* The id of the gist to display.
*/
@Input() set gistId(id: string) {
this._gistId = id;
this._iframeId = `gist-${id}`;
}

Since each fragment of a gist varies in size/height, iframe-resizer cannot calculate each individual component's height properly. This is because each iframe's height is calculated per id, resulting in stopping calculating other iframes with the same id.

Possible solution

To get around this issue, we need to append the filename (if provided) to the generated iframeId.

For example:

...

  /**
   * The file to display. If not specified, the first file in the gist will be displayed.
   */
  @Input() file?: string;

  /**
   * The id of the gist to display.
   */
  @Input() set gistId(id: string) {
    this._gistId = id;
    const fileId = this.file ? `-file=${this.file}` : ''`
    this._iframeId = `gist-${id}${fileId}`;
  }

...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.