Git Product home page Git Product logo

Comments (6)

jounia avatar jounia commented on May 18, 2024 1

Sure, but keep in mind it doesn't work without the "align" exception in _deriveSurrogateStyle:

case 'textAlign':
style.align = this._input_style.textAlign;
break

And I of course meant that I put the code in my previous post in _updateSurrogate function, apologies.

from pixi-text-input.

Mwni avatar Mwni commented on May 18, 2024

It would probably be easy to fix by adding an exception for it to the _deriveSurrogateStyle?

yes that should be a trivial fix. let me know if it works, otherwise i'll take a look.

from pixi-text-input.

jounia avatar jounia commented on May 18, 2024

I tried adding it there... The TextStyle gets the correct align property but for some reason the surrogate still stays to the left. Can you take a look?

from pixi-text-input.

jounia avatar jounia commented on May 18, 2024

Okay, I figured it out when trying to get sleep last night... 😄 Pixi.Text is of course only the width of the text it contains, so it has to be positioned manually, so in _deriveSurrogateStyle I put:

switch (this._surrogate.style.align) {
case 'left':
this._surrogate.x = padding[3];
break;
case 'center':
this._surrogate.x = input_bounds.width * 0.5 - this._surrogate.width * 0.5;
break;
case 'right':
this._surrogate.x = input_bounds.width - padding[1] - this._surrogate.width;
break;
}

And it works.

from pixi-text-input.

Mwni avatar Mwni commented on May 18, 2024

Nice one! Can I merge this code?

from pixi-text-input.

Mwni avatar Mwni commented on May 18, 2024

a7e48f4

from pixi-text-input.

Related Issues (20)

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.